Part Number Hot Search : 
2N2773 45PE40 MPC56 6143A W541C261 K1V10 RLZ11B FN1198
Product Description
Full Text Search
 

To Download DS51331B Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  ? 2005 microchip technology inc. DS51331B mplab ? icd 2 in-circuit debugger user?s guide www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page ii ? 2005 microchip technology inc. information contained in this publication regarding device applications and the like is provided only for your convenience and may be superseded by updates. it is your responsibility to ensure that your application meets with your specifications. microchip makes no representati ons or warranties of any kind whether express or implied, written or oral, statutory or otherwise, related to the information, including but not limited to its condition, quality, performance, merchantability or fitness for purpose. microchip discl aims all liability arising from this information and its use. use of microchip? s products as critical components in life support systems is not authorized except with express written approval by micro- chip. no licenses are conveyed, implicit ly or otherwise, under any microchip intel- lectual property rights. trademarks the microchip name and l ogo, the microchip logo, accuron, dspic, k ee l oq , micro id , mplab, pic, picmicro, picstart , pro mate, powersmart, rfpic and smartshunt are registered trademarks of microchip technology incorporated in the u.s.a. and other countries. amplab, filterlab, migratable memory, mxdev, mxlab, picmaster, seeval, smartsensor and the embedded control so lutions company are registered trademarks of microchip technology incorporated in the u.s.a. analog-for-the-digital age, applicatio n maestro, dspicdem, dspicdem.net, dspicworks, ecan, economonitor, f ansense, flexrom, fuzzylab, in- circuit serial programming, icsp, icepic , linear active thermistor, microport, mpasm, mplib, mplink, mpsim, picc, pickit, picdem, picdem.net, piclab, pictail, powercal, powerinfo, powermate , powertool, rflab, rfpicdem, select mode, smart serial, smarttel, total e ndurance and wiperlock are trademarks of microchip technology incorporated in the u.s.a. and other countries. sqtp is a service mark of microchip technology in corporated in the u.s.a. all other trademarks mentioned herein are property of their respective companies. ? 2005, microchip technology incorporat ed, printed in the u.s.a., all rights reserved. printed on recycled paper. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
? 2005 microchip technology inc. DS51331B-page iii mplab ? icd 2 user?s guide customer support................. ................................... 1 chapter 1. mplab icd 2 overview 1.1 introduction .................................................................... 7 1.2 what is mplab icd 2? ................................................. 7 1.3 how mplab icd 2 helps you ....................................... 8 1.4 how mplab icd 2 works ............................................. 8 1.5 resources used by mplab icd 2 .............................. 18 chapter 2. getting started 2.1 introduction .................................................................. 27 2.2 mplab icd 2 system components ............................ 28 2.3 installing and configuring mplab ide for mplab icd 2 .................................................................... 29 2.4 applying power ............................................................ 32 2.5 connection options ..................................................... 34 2.6 setting up the environment ......................................... 34 2.7 mplab icd 2 development process .......................... 36 chapter 3. mplab icd 2 tutorial 3.1 introduction .................................................................. 43 3.2 setting up the environment ........................................ 44 3.3 running the project wizard ......................................... 47 3.4 viewing the project ...................................................... 50 3.5 creating a hex file ...................................................... 51 3.6 setting debug options ................................................. 52 3.7 setting up the demo board ......................................... 54 3.8 loading program code for debugging ....................... 54 3.9 running tut452 ......................................................... 55 3.10 debugging tut452 ................................................... 56 table of contents www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab ? icd 2 user?s guide DS51331B-page iv ? 2005 microchip technology inc. 3.11 programming the application .....................................61 3.12 tut452 main routine and source code ...................62 chapter 4. advanced usage 4.1 introduction ...................................................................67 4.2 upgrading the mplab icd 2 firmware (operating system) ............................................................67 4.3 creating/loading a hex file .........................................68 4.4 special linker script files ............................................69 4.5 romless device co nsiderations ..................................70 4.6 special icd devices .....................................................72 chapter 5. icd function summary 5.1 introduction ...................................................................73 5.2 debugging func tions ...................................................73 5.3 programming functions ...............................................77 5.4 settings dialog .............................................................79 5.5 setup wizard ................................................................84 5.6 advanced breakpoints dialog ......................................87 chapter 6. troubleshooting tips 6.1 introduction ...................................................................95 6.2 link: pc to icd communications .................................96 6.3 link: icd firmware .......................................................97 6.4 link: icd to target picmicro device ...........................97 6.5 link: target power .......................................................98 6.6 link: target o scillator ..................................................99 6.7 link: application code ................................................100 6.8 link: debug executive ................................................100 6.9 link: in-circuit debug registers .................................101 6.10 link: in-circuit debug resources .............................101 www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
? 2005 microchip technology inc. DS51331B-page v table of contents chapter 7. self test 7.1 introduction ................................................................ 103 7.2 target v dd ................................................................. 103 7.3 module v pp ................................................................ 104 7.4 mclr = gnd ............................................................. 104 7.5 mclr = v dd .............................................................. 105 7.6 mclr = v pp .............................................................. 105 7.7 failed self test error ? v pp /v dd high/low ............... 106 chapter 8. general troubleshooting 8.1 introduction ................................................................ 107 8.2 frequently asked questions ...................................... 107 8.3 common communication problems .......................... 114 8.4 common problems .................................................... 119 8.5 error and warning messages .................................... 122 8.6 limitations .................................................................. 123 chapter 9. hardware specifications 9.1 introduction ................................................................ 125 9.2 mplab icd 2 module ................................................ 125 9.3 modular cable and connector ................................... 126 9.4 power supply ............................................................. 129 index................................. ..................................... 131 worldwide sales and service ............................. 138 www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab ? icd 2 user?s guide DS51331B-page vi ? 2005 microchip technology inc. notes: www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
? 2005 microchip technology inc. DS51331B-page 1 mplab ? icd 2 user?s guide customer support notice to customers all documentation becomes dated, and this manual is no exception. microchip tools and documentation are constantly evolving to meet customer needs, so some actual dialogs and/or tool descriptions may differ from those in this document. please refer to our web site (www.microchip.com) to obtain the latest documentation available. documents are identified with a ?ds? number. this number is located on the bo ttom of each page, in front of the page number. the numbering convention for the ds number is ?dsxxxxxa?, where ?xxxxx? is the document number and ?a? is the revision level of the document. for the most up-to-date information on development tools, see the mplab ? ide on-line help. select the help menu, and then topics to open a list of available on-line help files. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 2 ? 2005 microchip technology mplab ? icd 2 user?s guide introduction the support information discussed here can help you when using the mplab icd 2 in-circuit debugger. topics covered in this chapter: ? reference documents ? the microchip web site ? development systems customer change notification ? contact information reference documents this document describes how to use mplab icd 2. other useful documents are listed below. mplab ? icd 2 design advisory (ds51566) please read this first! contains im portant information about using the mplab icd 2 with your target design. readme for mplab icd 2 for the latest information on using mplab icd 2, read the readme for mplab icd 2.txt file (an ascii text file) in the mplab ide directory. the readme file contains update information and known issues that may not be in cluded in this on-line help file. using mplab ? icd 2 (ds51265) a poster showing the various ways you can set up mplab icd 2 hardware. mplab ? icd 2 header (ds51292) a small booklet describing how to install and use mplab icd 2 headers. headers are used to better debug selected devices, using special -icd device versions, without the loss of pins or resources. universal programming module instruction sheet (ds51280) a sheet describing how to use the upm. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
customer support ? 2005 microchip technology inc. DS51331B-page 3 the microchip web site microchip provides online support via our web site at www.microchip.com. this web site is used as a means to make files and information easily availabl e to customers. accessible by using your favorite internet browser, the web site contains the following information: ? product support ? data sheets and errata, application notes and sample programs, design resources, user?s guides and hardware support documents, latest software releases and archived software ? general technical support ? frequently asked questions (faqs), technical support requests, online discussion groups, microchip consultant program member listing ? business of microchip ? product selector and ordering guides, latest microchip press releases, listing of seminars and events, listings of microchip sales offices, distributors and factory representatives www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 4 ? 2005 microchip technology mplab ? icd 2 user?s guide development systems customer change notification microchip?s customer notification service helps keep customers current on microchip products. subs cribers will receive e-mail notification whenever there are changes, updates, revisions or errata related to a specified product family or development tool of interest. to register, access the microchip web site at www.microchip.com, click on customer change notification and follow the registration instructions. the development systems product group categories are: ? compilers ? the latest information on microchip c compilers and other language tools. these include the mplab c18 and mplab c30 c compilers; mpasm? and mplab asm30 assemblers; mplink? and mplab link30 object linkers; and mplib? and mplab lib30 object librarians. ? emulators ? the latest information on microchip in-circuit emulators. this includes the mplab ice 2000 and mplab ice 4000. ? in-circuit debuggers ? the latest information on the microchip in-circuit debugger, mplab icd 2. ? mplab ? ide ? the latest information on microchip mplab ide, the windows ? integrated development environment for development systems tools. this list is focused on the mplab ide, mplab ide project manager, mplab editor and mplab sim simulator, as well as general editing and debugging features. ? programmers ? the latest information on microchip pro- grammers. these include the mplab pm3 and pro mate ? ii device programmers and the picstart ? plus and pickit? 1 development programmers. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
customer support ? 2005 microchip technology inc. DS51331B-page 5 contact information users of microchip products can receive assistance through several channels: ? distributor or representative ? local sales office ? field application engineer (fae) ? technical support customers should contact their distributor, representative or field application engineer (fae) for suppor t. local sales offices are also available to help customers. a listing of sales offices and locations is included in the back of this document. technical support is available through the web site at: http://support.microchip.com www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 6 ? 2005 microchip technology mplab ? icd 2 user?s guide notes: www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
? 2005 microchip technology inc. DS51331B-page 7 mplab ? icd 2 user?s guide chapter 1. mplab icd 2 overview 1.1 introduction an overview of the mplab icd 2 development tool is given here. mplab icd 2 is defined and its operation explained. additionally, device resources used during debugging are listed. topics covered in this chapter are: ? what is mplab icd 2? ? how mplab icd 2 helps you ? how mplab icd 2 works ? resources used by mplab icd 2 1.2 what is mplab icd 2? the mplab icd 2 is a low-cost in-circuit debugger (icd) and in-circuit serial programmer? (icsp?). mplab icd 2 is intended to be used as an evaluation, debugging and programming aid in a laboratory environment. the mplab icd 2 offers these features: ? real-time and single-step code execution ? breakpoints, register and variable watch/modify ? in-circuit debugging ? target v dd monitor ? diagnostic leds ? mplab ide user interface ? rs-232 serial or usb interface to a host pc www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 8 ? 2005 microchip technology mplab ? icd 2 user?s guide 1.3 how mplab icd 2 helps you the mplab icd 2 allows you to: ? debug your source code in your own application ? debug your hardware in real-time ? program a supported device using microchip's icsp protocol 1.4 how mplab icd 2 works a simplified description of how mplab icd 2 works is provided here. it is intended to provide enough information so a target board can be designed that is compatible with mplab icd 2 for both programming and debugging operations. the basic theory of programming and in-circuit debugging is described so that problems, if encountered, are quickly resolved. this section provides an overview of mplab icd 2, followed by a description of mplab icd 2 programming and debugging modes. the following topics are covered: ? icd vs. ice ? modular interface connections ? circuits that will prevent mplab icd 2 from functioning ? debug mode ? requirements for debug mode ? debug reserved resources ? programmer mode 1.4.1 icd vs. ice the in-circuit debugger (icd) is a cost-efficient alternative to an in-circuit emulator (ice). it can do many things that were previously done only with more expensive hardware, but the cost benefits come with a trade-off of some of the conveniences of an in-circuit emulator. if users are wi lling to design their application to be icd compatible, they can enjoy the benefits of a low-cost hardware debugger. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab icd 2 overview ? 2005 microchip technology inc. DS51331B-page 9 as opposed to an ice, some of the requirements of the in-circuit debugger are: ? the in-circuit debugger requires exclusive use of some hardware and software resources of the target. ?the target picmicro ? mcu must have a functioning clock and be running. ? the icd can debug only when all the links in the system are fully functional. an emulator provides memory and a clock, and can run code ? even without being connected to the target application board. during the development and debugging cycle, an ice provides the most power to get the system fully functional, whereas an icd may not be able to debug at all if the application does not run. on the other hand, an in-circuit debug connector can be placed on the application board and connected to an icd even after the system is in production, allowing easy testing, debugging and reprogram- ming of the application. even though an icd has some drawbacks in comparison to an ice, in this situation it has some distinct advantages: ? a connection to the application after the production cycle does not require extraction of the microcontroller in order to insert an ice probe. ? the icd can re-program the firmware in the target application without any other connections or equipment. note: an ice uses custom hardware to emulate the target microcontroller. an icd uses hardware on the target microcontroller to do some of the functions of an ice. an icd also employs software running on the target to do ice-like functions and, as a result, relies upon the target microcontroller for some memory space, cpu control, stack storage and i/o pins for communication. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 10 ? 2005 microchip technology mplab ? icd 2 user?s guide 1.4.2 modular interface connections mplab icd 2 is connected to the target picmicro mcu with the modular interface cable, a six conductor cable. the pin numbering for the mplab icd 2 connector is shown from the bottom of the target pc board in figure 1-1. figure 1-1: pin numbering for modular connector figure 1-2 shows the interconnections of the mplab icd 2 to the modular connector on the target board. there are six pins on the icd connector, but only five are used. the diagram also shows the wiring from the connector to the picmicro mcu device on the target pc board. a pull-up resistor (usually around 10k ohm) is recommended to be connected from the v pp /mclr line to v dd so that the line may be strobed low to reset the picmicro mcu. note: the icd cable has mirror imaged connections on each end, and connections on the mplab icd 2 module are the opposite of connections shown here. 1 2 3 4 5 6 mplab ? icd 2 connector target bottom side pc board v pp /mclr v ss pgc v dd pgd www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab icd 2 overview ? 2005 microchip technology inc. DS51331B-page 11 figure 1-2: mplab ? icd 2 connections to target board although pin 2 (v dd ) can supply a limited amount of power to the target application under certain conditions, for the purposes of these descriptions, pins 2 and 3 (v ss ) are omitted. they are shown on the diagram for completeness, but in the following descriptions only three lines are active and relevant to core mplab icd 2 operation: v pp /mclr , pgc and pgd. not all picmicro mcus have the av dd and av ss lines, but if they are present on the target picmicro mcu, all must be connected in order for mplab icd 2 to operate. note: in the following discussions, v dd is ignored. but be aware that the target v dd is also used to power the output drivers in mplab icd 2. this allows level translation for target low-voltage operation. if mplab icd 2 does not have voltage on its v dd line (pin 2 of the icd connector), either from power being supplied to the target by mplab icd 2 or from a separate target power supply, it will not operate. v dd v pp /mclr pgc pgd v ss av dd av ss 2 1 5 4 3 user reset 1k - 10k mplab ? icd 2 interface connector application pc board picxxxx www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 12 ? 2005 microchip technology mplab ? icd 2 user?s guide the interconnection is very simple, any problems experienced are often caused by other connections or components on these critical lines that interfere with the operation of mplab icd 2, as discussed in section 1.4.3. 1.4.3 circuits that will prevent mplab icd 2 from functioning figure 1-3 shows the active mplab icd 2 lines with some components that will prevent mplab icd 2 from functioning: figure 1-3: improper circuit components specifically, these guidelines must be followed: ? no pull-ups on pgc/pgd ? they will divide the voltage levels, since these lines have 4.7k pull-down resistors in mplab icd 2. ? no capacitors on pgc/pgd ? they will prevent fast transitions on data and clock lines during programming and debug communications. ? no capacitors on mclr ? they will prevent fast transitions of v pp . a simple pull-up resistor is generally sufficient. no! no! no! no! v pp /mclr pgc pgd 1 5 4 www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab icd 2 overview ? 2005 microchip technology inc. DS51331B-page 13 ? no diodes on pgc/pgd ? they will prevent bidirectional communication between mplab icd 2 and the target picmicro mcu. 1.4.4 debug mode there are two steps to using mplab icd 2 as a debugger. the first requires that an application be programmed into the target picmicro mcu. the second uses the internal in-circuit debug hardware of the target flash picmicro mcu to run and test the application program. these two steps are directly related to the mplab ide operations: 1. programming the code into the target. 2. using the debugger to set breakpoints and run. if the target picmicro mcu cannot be programmed correctly, mplab icd 2 will not be able to debug. figure 1-4 shows the basic interconnections required for programming. note that this is th e same as figure 1-2, but for the sake of clarity, the v dd and v ss lines from mplab icd 2 are not shown. figure 1-4: proper connections for programming +5v programming 4.7k 4.7k v pp /mclr pgc pgd 1 5 4 mplab ? icd 2 internal circuits v ss v dd voltage www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 14 ? 2005 microchip technology mplab ? icd 2 user?s guide a simplified diagram of some of the internal interface circuitry of the mplab icd 2 is shown. for programming, no clock is needed on the target picmicro mcu, but power must be supplied. when programming, mplab icd 2 puts programming levels on v pp , sends clock pulses on pgc and serial data via pgd. to verify that the part has been programmed correctly, clocks are sent to pgc and data is read back from pgd. this conforms to the icsp? protocol of the picmicro mcu under development. 1.4.5 requirements for debug mode to debug (set breakpoints, see registers, etc.) with the mplab icd 2 there are critical elements that must be working correctly: ? mplab icd 2 must be connected to a pc. it must be powered by an external power supply or the pc via the usb cable, and it must be communicating with mplab ide software via the rs-232 or usb cable. see the on-line help for details. ? the mplab icd 2 must be connected as shown to the v pp , pgc and pgd pins of the target picmicro mcu with the modular interface cable (or equivalent). v ss and v dd are also required to be connected between the mplab icd 2 and target picmicro mcu. ? the target picmicro mcu must have power and a functional, running oscillator. if the target picmicro mcu does not run ? for whatever reason ? mplab icd 2 cannot debug. ? the target picmicro mcu must have its configuration words programmed correctly: - the oscillator configuration bits should correspond to rc, xt, etc., depending upon the target design. - the target picmicro mcu must not have the watchdog timer enabled. - the target must not have code protection enabled. - the target must not have table read protection enabled. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab icd 2 overview ? 2005 microchip technology inc. DS51331B-page 15 once the above conditions are met, you may proceed to the ollowing: ? sequence of operations leading to debug mode ? debug mode details 1.4.5.1 sequence of operations leading to debug mode given that the requirements for debug mode are met, these actions can be performed when mplab icd 2 is set as the current debugger ( debugger>select tool ): ? when debugger>program is selected, the application code is programmed into the picmicro mcu?s memory via the icsp protocol as described above. ? a small ?debug executive? program is loaded into the high area of program memory of the target picmicro mcu. since the debug executive must reside in program memory, the application program must not use this reserved space. the debug executive typically needs about 0x120 words of program memory. ? special ?in-circuit debug? registers in the target picmicro mcu are enabled. these allow the debug executive to be activated by the mplab icd 2. ? the target picmicro mcu is held in reset by keeping the v pp /mclr line low. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 16 ? 2005 microchip technology mplab ? icd 2 user?s guide 1.4.5.2 debug mode details figure 1-5 illustrates the mplab icd 2 ready for debugging. figure 1-5: mplab ? icd 2 ready for debugging typically, in order to find out if an application program will run correctly, a breakpoint is set early in the program code. when a breakpoint is set from the user interface of the mplab ide, the address of the breakpoint is stored into the special internal debug registers of the target picmicro mcu. commands on pgc and pgd communicate directly to these registers to set the breakpoint address. next, the debugger>run function or the run icon (forward arrow) is usually pressed from mplab id e. mplab icd 2 will raise the v pp /mclr line to allow the target to run, the target will start from address zero and execute until the program counter reaches the breakpoint address previously stored in the internal debug registers. +5v +12v 4.7k 4.7k mplab ? icd 2 internal circuits program memory file registers internal debug registers v pp /mclr pgc pgd 1 5 4 executive debug about 0x10 bytes used by ta r g e t be running must for debug executive to function area v dd hardware stack shared by debug exec debug exec reserved for debug executive www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab icd 2 overview ? 2005 microchip technology inc. DS51331B-page 17 after the instruction at the breakpoint address is executed, the in-circuit debug mechanism of the target picmicro mcu ?fires? and transfers the picmicro mcu? s program counter to the debug executive (much like an interrupt) and the user?s application is effectively halted. mplab icd 2 communicates with the debug executive via pgc and pgd, gets the breakpoint status information and sends it back to the mplab ide. the mplab ide then sends a series of queries to mplab icd 2 to get information about the target picmicro mcu, su ch as file register contents and the state of the cpu. these queries are ultimately performed by the debug executive. the debug executive runs just like an application in program memory. it uses some locations on the hardware stack (usually just one or two) and, typically, about fourteen file registers for its temporary variables. if the picmicro mcu does not run, for whatever reason, such as no oscillator, a faulty power supply connection, shorts on the target board, etc., then the debug executive cannot communicate to mplab icd 2 and mplab ide will issue an error message. another way to get a breakpoint is to press the mplab ide?s halt button (the ?pause? symbol to the right of the run arrow). this tog- gles the pgc and pgd lines in such a way that the in-circuit debug mechanism of the target picmicro mcu switches the program counter from the user?s code in program memory to the debug executive. again, the target application program is effectively halted, and mplab ide uses mplab icd 2 communications with the debug executive to interrogate t he state of the target picmicro mcu. 1.4.6 debug reserved resources when developing with mplab icd 2, you must be aware of the device resources reserved for debugging. see section 1.5 ?resources used by mplab icd 2? for a list of reserved resources by device type. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 18 ? 2005 microchip technology mplab ? icd 2 user?s guide 1.4.7 programmer mode when using the programmer>program selection to program a device, the in-circuit debug registers should be disabled in the mplab ide so the mplab icd 2 will program only the target application code and the configuration bits (and eeprom data, if available and selected) into the target picmicro mcu. the debug executive will not be loaded. in this mode the mplab icd 2 can only toggle the mclr line to reset and start the target. a breakpoint cannot be set, and register contents cannot be seen or altered. the mplab icd 2 programs the target using icsp. no clock is required while programming, and all modes of the processor can be programmed, including code protect, watchdog timer enabled and table read protect. 1.5 resources used by mplab icd 2 due to the built-in in-circuit debugging capability of icd devices, and the icsp function offered by the debugger, the mplab icd 2 uses the following on-chip resources when debugging: ? resources used for pic10f/12f devices ? resources used for pic16f devices ? resources used for pic18x devices ? resources used for dspic30f devices note: a header board is required to debug smaller pin count parts with the mplab icd 2. these parts can be programmed without the header by connecting the v pp , pgc and pgd lines as described previously. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab icd 2 overview ? 2005 microchip technology inc. DS51331B-page 19 1.5.1 resources used for pic10f/12f devices general device resources ?mclr pin reserved for debugging, except for -icd devices, i.e., you cannot use this pin as digital i/o while debugging. ?mclr /v pp shared for programming. ? gp0 and gp1 reserved for programming and in-circuit debugging. therefore, other functions multiplexed on these pins will not be available during debug. ? one stack level not available. program and data memory resources the mplab icd 2 uses the followi ng program memory, file regis- ter and data memory locations in the target device. in mplab ide, registers marked with an "r" in register displays represent reserved registers. device program memory used file registers used pic12f629-icd 0x300-0x3ff 0x54-0x5f 0xd4-0xdf pic12f635-icd 0x300-0x3ff 0x65-0x6f 0x70, 0xf0 0x170, 0x1f0 pic12f675-icd 0x300-0x3ff 0x54-0x5f 0xd4-0xdf pic12f683-icd 0x700-0x7ff 0x65-0x6f 0x70, 0xf0 www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 20 ? 2005 microchip technology mplab ? icd 2 user?s guide 1.5.2 resources used for pic16f devices general device resources ?mclr pin reserved for debugging, except for -icd devices, i.e., you cannot use this pin as digital i/o while debugging. ?mclr /v pp shared for programming. ? low-voltage icsp programming disabled for devices that support this type of programming. ? rb6 and rb7 reserved for programming and in-circuit debugging. (exception: ra0 and ra1 reserved on pic16f630/676.) therefore, other functions multiplexed on these pins will not be available during debug. ? one stack level not available. program and data memory resources the mplab icd 2 uses the following program memory, file regis- ter and data memory locations in the target device. in mplab ide, registers marked with an "r" in register displays represent reserved registers. note: mplab icd 2 does not support low voltage programming. mplab icd 2 will disable this function. you cannot enable it through programming using the mplab icd 2. however, you can enable it through another programmer (e.g., picstart ? plus development programmer.) device program memory used file registers used pic16f627a-icd 0x300-0x3ff 0x70, 0xf0 0x165-0x16f 0x170, 0x1f0 pic16f628a-icd 0x700-0x7ff pic16f630-icd 0x300-0x3ff 0x54-0x5f 0xd4-0xdf pic16f636-icd pic16f639-icd 0x700-0x7ff 0x65-0x6f 0x70, 0xf0 0x170, 0x1f0 www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab icd 2 overview ? 2005 microchip technology inc. DS51331B-page 21 pic16f648a-icd 0xf00-0xfff 0x70, 0xf0 0x165-0x16f 0x170, 0x1f0 pic16f676-icd 0x300-0x3ff 0x54-0x5f 0xd4-0xdf pic16f684-icd 0x700-0x7ff 0x65-0x6f 0x70, 0xf0 0x165-0x16f 0x170, 0x1f0 pic16f685-icd pic16f687-icd pic16f688-icd 0xf00-0xfff 0x70, 0xf0 0x165-0x16f 0x170, 0x1f0 pic16f689-icd 0x700-0x7ff 0x65-0x6f 0x70, 0xf0 0x170, 0x1f0 pic16f690-icd 0xf00-0xfff pic16f716 0x700-0x7ff 0x65-0x6f 0x70, 0xf0 pic16f737/747 0x0f00-0x0fff 0x70, 0xf0, 0x165-0x16f 0x170, 0x1f0 pic16f767/777 0x1f00-0x1fff pic16f785 0x700-0x7ff 0x65-0x6f 0x70, 0xf0 0x170, 0x1f0 pic16f87/88 0xf00-0xfff 0x70, 0xf0 0x170, 0x1f0 0x1e7-0x1ef pic16f818 0x300-0x3ff 0x65-0x70 0xe5-0xf0 0x165-0x170 0x1e5-0x1f0 pic16f819 0x700-0x7ff 0x65-0x70 0xf0, 0x170 0x1e5-0x1f0 device program memory used file registers used www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 22 ? 2005 microchip technology mplab ? icd 2 user?s guide 1.5.3 resources used for pic18x devices general device resources ?mclr pin reserved for debugging, except for -icd devices, i.e., you cannot use this pin as digital i/o while debugging. ?mclr /v pp shared for programming. ? low-voltage icsp programming disabled for devices that support this type of programming. ? rb6 and rb7 reserved for programming and in-circuit debugging. therefore, other functions multiplexed on these pins will not be available during debug. ? two stack levels not available. also, because mplab icd 2 needs to control the stack, tos registers (tosl, tosh, tosu) are reserved. pic16f870/871/872 0x700-0x7ff 0x70, 0xf0 0xb5-0xbf 0x170, 0x1f0 0x1b5-0x1bf pic16f873/873a pic16f874/874a 0xf00-0xfff 0x7e-0x7f 0xf4-0xff 0x17e-0x17f 0x1f4-0x1ff pic16f876/876a pic16f877/877a 0x1f00-0x1fff 0x70, 0xf0 0x170, 0x1f0 0x1e5-0x1ef pic16f913/914 0xf00-0xfff 0x70, 0xf0 0x165-0x16f 0x170, 0x1f0 pic16f916/917 pic16f946 0x1ff0-0x1fff note: mplab icd 2 does not support low voltage programming. mplab icd 2 will disable this function. you cannot enable it through programming using the mplab icd 2. however, you can enable it through another programmer (e.g., picstart plus development programmer.) device program memory used file registers used www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab icd 2 overview ? 2005 microchip technology inc. DS51331B-page 23 program and data memory resources the mplab icd 2 uses some program memory, file register and data memory locations in the target device, as specified below. in mplab ide, registers marked with an "r" in register displays (windows) in mplab ide represent reserved registers. select the pic18x device you are using to see the reserved resources. ? pic18cxxx/fxxx, pic18f1xxx devices ? pic18f2xxx/4xxx devices ? pic18f6xxx/8xxx devices 1.5.3.1 pic18cxxx/fxxx, pic18f1xxx devices below are the program and data memory resources used by mplab icd 2 for pic18cxxx/fxxx devices. below are the program and data memory resources used by mplab icd 2 for pic18f1xxx devices. device program memory used file registers used pic18c601 pic18c801 0x1ffe00-0x1fffff (boot ram) 0x3f4-0x3ff pic18f242 pic18f248 pic18f442 pic18f448 0x3dc0-0x3fff 0x2f4-0x2ff pic18f252 pic18f258 pic18f452 pic18f458 0x7dc0-0x7fff 0x5f4-0x5ff device program memory used file registers used pic18f1220 0x0e40-0x0fff 0xf0-0xff pic18f1320 0x1e40-0x1fff www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 24 ? 2005 microchip technology mplab ? icd 2 user?s guide 1.5.3.2 pic18f2xxx/4xxx devices below are the program and data memory resources used by mplab icd 2 for pic18f2xxx/4xxx devices. device program memory used file registers used pic18f2220/4220 0x0dc0-0x0fff 0x1f4-0x1ff pic18f2221/4221 0x1dc0-0x1fff pic18f2320/4320 0x1dc0-0x1fff pic18f2321/4321 0x0dc0-0x0fff pic18f2331/4331 0x1dc0-0x1fff 0x2f4-0x2ff pic18f2410/4410 pic18f2420/4420 pic18f2431/4431 0x3dc0-0x3fff 0x2f4-0x2ff pic18f2439 0x3dc0-0x3fff 0x5f4-0x5ff pic18f4439 0x2f4-0x2ff pic18f2455/4455 0x5dc0-0x5fff 0x3f4-0x3ff pic18f2480/4480 0x3dc0-0x3fff 0x2f4-0x2ff pic18f2510/4510 0x7dc0-0x7fff 0x5f4-0x5ff pic18f2515/4515 0xbd80-0xbfff 0xef4-0xeff pic18f2520/4520 0x7dc0-0x7fff 0x5f4-0x5ff pic18f2525/4525 0xbd80-0xbfff 0xef4-0xeff pic18f2539/4539 0x7dc0-0x7fff 0x5f4-0x5ff pic18f2550/4550 0x7dc0-0x7fff 0x3f4-0x3ff pic18f2580/4580 0x7dc0-0x7fff 0x5f4-0x5ff pic18f2585/4585 0xbd80-0xbfff 0xcf4-0xcff pic18f2610/4610 pic18f2620/4620 0xfd80-0xffff 0xef4-0xeff pic18f2680/4680 pic18f2681/4681 0xfd80-0xffff 0xcf4-0xcff www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab icd 2 overview ? 2005 microchip technology inc. DS51331B-page 25 1.5.3.3 pic18f6xxx/8xxx devices below are the program and data memory resources used by mplab icd 2 for pic18f6xxx/8xxx devices. device program memory used file registers used pic18f6310/8310 pic18f6390/8390 0x1dc0-0x1fff 0x2f4-0x2ff pic18f6410/8410 pic18f6490/8490 0x3dc0-0x3fff 0x2f4-0x2ff pic18f6520/8520 0x7d80-0x7fff 0x7f4-0x7ff pic18f6525/8525 pic18f6585/8585 0xbd80-0xbfff 0xcf4-0xcff pic18f6620/8620 0xfd80-0xffff 0xef4-0xeff pic18f6621/8621 0xcf4-0xcff pic18f6627/8627 0x17d80-0x17fff 0x7f4-0x7ff pic18f6680/8680 0xfd80-0xffff 0xcf4-0xcff pic18f6720/8720 0x1fd80-0x1ffff 0xef4-0xeff pic18f6722/8722 0x1fd80-0x1ffff 0x7f4-0x7ff pic18f67j10/87j10 0x1fdb8-0x1fff7 ? www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 26 ? 2005 microchip technology mplab ? icd 2 user?s guide 1.5.4 resources used for dspic30f devices general device resources ?mclr pin reserved for debugging, except for -icd devices, i.e., you cannot use this pin as digital i/o while debugging. ?mclr /v pp shared for programming. ? pgc and pgd reserved for programming. therefore, other functions multiplexed on these pins will not be available during debug. program and data memory resources the mplab icd 2 uses the following program memory, file register and data memory locations in the target device. in mplab ide, registers marked with an "r" in register displays represent reserved registers. device program memory used file registers used dspic30fxxxx none* 0x800-0x822 * no user program memory space used for icd. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
? 2005 microchip technology inc. DS51331B-page 27 mplab ? icd 2 user?s guide chapter 2. getting started 2.1 introduction the use of mplab icd 2 with mplab ide software and an expla- nation of power options and recommended power-up sequences are discussed here. following this is a step-by-step tutorial using mplab icd 2. before continuing on to the tutorial, be sure that the software and hardware is configured according to the instructions given here. in addition, please refer to the ?mplab icd 2 design advisory? (ds51566) for hardware configuration issues. topics covered in this chapter: ? mplab icd 2 system components ? installing and configuring mplab ide for mplab icd 2 ? applying power ? connection options ? setting up the environment ? mplab icd 2 development process www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 28 ? 2005 microchip technology mplab ? icd 2 user?s guide 2.2 mplab icd 2 system components in addition to the mplab icd 2 module, the following components are required: ? mplab ide software (version 6.20 or later) ? installed on the pc to control mplab icd 2. ? rs-232 or usb cable ? to connect the mplab icd 2 module to a com or usb port on the pc. ? modular interface cable ? to connect the mplab icd 2 module to a demo board or the user?s application. ? demo board or target application ? to connect the picmicro mcu with on-board debug capabilities to the modular interface (and the mplab icd 2). although the serial or usb communications from the mplab ide to the mplab icd 2 can be set up without a target connection, mplab icd 2 will not function as a debugger without being connected to a target. ? power adapter(s) ? to power mplab icd 2 and the target application. note: do not connect the usb cable until installation of the mplab ide software and instructions for configuring the usb driver have been completed. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
getting started ? 2005 microchip technology inc. DS51331B-page 29 2.3 installing and configuring mplab ide for mplab icd 2 to install the mplab ide software, first acquire the latest mplab ide installation executable ( mpxxxxx.exe , where xxxxx represents the version of mplab ide) from either the microchip web site (www.microchip.com) or the mplab ide cd-rom (ds51123). ? setting up communications ? starting mplab ide ? select the device ? set mplab icd 2 as the debug tool ? configure the interface 2.3.1 setting up communications mplab icd 2 can communicate with the pc serially or using usb. 2.3.1.1 serial communications if using the rs-232 cable, connect it to the mplab icd 2 and the pc. note: when using the usb cable, do not connect it before installing mplab ide software. note: do not connect both rs-232 and usb cables to mplab icd 2. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 30 ? 2005 microchip technology mplab ? icd 2 user?s guide 2.3.1.2 usb communications instructions are supplied with mplab ide to install the usb drivers. these instructions will pop up during mplab ide installation. if you accidentally cl ose these instructions, they may be found at: mplab ide installation directory\icd2\drivers\ddicd2 nn .htm where nn represents the version of windows os. if the instruc- tions support more than one version, no os version ( nn ) will be specified. 2.3.2 starting mplab ide after installing the mplab ide software, invoke it by using any of these methods: ?select start>programs>microchip>mplab ide vx.xx>mplab ide , where vx.xx is the version number. ? double click the mplab ide desktop icon. ? execute the file mplab.exe in the \core subdirectory of the mplab ide installation directory. for more information on using the mplab ide software, see: -?mplab ? ide user?s guide? (ds51519) ? comprehensive guide for using mplab ide. - ?mplab ? ide quick start guide? (ds51281) ? chapters 1 and 2 of the user?s guide. - the on-line help for mplab ide ? the most up-to-date information on mplab ide. - the file readme for mplab ide.txt ? last-minute information on each release. included in the mplab ide installation directory. - also see the file readme for mplab icd 2.txt for the most current information about mplab icd 2. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
getting started ? 2005 microchip technology inc. DS51331B-page 31 after starting mplab ide, it wi ll need to be configured for mplab icd 2 use: 1. select a device supported by mplab icd 2. 2. set mplab icd 2 as the current debugger. 3. configure the mplab icd 2 rs-232 or usb interface. 2.3.3 select the device use the device selection dialog ( configure>select device ) to select the device to be debugged with the mplab icd 2. devices supported by mplab icd 2 will have a ?green light? icon next to mplab icd 2 under microchip tool support. devices not supported will have a ?red light? icon. a ?yellow light? icon indicates that a part may be selected, but it is available with possible limitations and may not be suitable for production work, but is released for preliminary use with mplab icd 2. 2.3.4 set mplab icd 2 as the debug tool select debugger>select tool>mplab icd 2 to choose mplab icd 2 as the debug tool. the debugger menu and mplab ide toolbar will change to display debug options once the tool is selected. also, the output window will open and messages concerning icd status and communications will be displayed on the mplab icd 2 tab. 2.3.5 configure the interface go to the debugger>settings , communications tab to select the usb interface or the correct com port for rs-232 communications. note: mplab icd 2 may be selected as either a debug tool (debugger menu) or a programmer (programmer menu). do not select both. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 32 ? 2005 microchip technology mplab ? icd 2 user?s guide 2.4 applying power there are a number of configur ations for powering mplab icd 2 and the target. the following are configuration essentials: ? when using the usb connection, mplab icd 2 can be powered from the pc but a power supply must be connected to the target. ? when using the rs-232 connection to the pc, mplab icd 2 must have a power supply connected to it. ? when mplab icd 2 has its own power supply, it can provide a limited amount of current, up to 200 ma, at five volts to a small target board. ? mplab icd 2 cannot be powered from the target board. ? power should be applied to mplab icd 2 before applying power to the target. there are two power-up sequences for the icd: ? power sequence when mplab icd 2 is providing power to the target ? power sequence when target has a separate power supply 2.4.1 power sequence when mplab icd 2 is providing power to the target use this sequence to power the ta rget board from mplab icd 2. this configuration allows up to 200 ma of current at 5 volts only. 1. apply power to mplab icd 2. do not power the target. 2. start mplab ide. 3. under the debugger menu of mplab ide, select connect . 4. after establishing communications with the mplab icd 2, select debugger>settings . www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
getting started ? 2005 microchip technology inc. DS51331B-page 33 5. in the settings dialog, click the power tab and ensure that the check box for ?power target circuit from mplab icd 2? is checked. click ok . 2.4.2 power sequence when target has a separate power supply use this sequence to power the target board from its own power supply. for this configuration, the target power can be 2-5 volts at higher currents than can be provided by the mplab icd 2 (>200 ma). check the picmicro mcu data sheet to verify the operational voltage range for the device being used. 1. apply power to mplab icd 2. do not power the target. 2. start mplab ide. 3. under the debugger menu of mplab ide, select connect . 4. after establishing communications with the mplab icd 2, select debugger>settings . 5. in the settings dialog, click the power tab and ensure that the check box for ?power target circuit from mplab icd 2? is not checked. click ok . 6. power the target system and then select debugger>connect . note: if any of the self-tests on the status tab of the settings dialog do not pass, it may not be possible to erase and program chips. see section 7.7 ?failed self test error ? v pp /v dd high/low? for more information. note: if any of the self-tests on the status tab of the settings dialog do not pass, it may not be possible to erase and program chips. see section 7.7 ?failed self test error ? v pp /v dd high/low? for more information. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 34 ? 2005 microchip technology mplab ? icd 2 user?s guide 2.5 connection options once you have initially connected with the mplab icd 2, you may continue to manually connect each time you select the icd as a debugger (by using debugger>connect ) or you may set the icd to connect automatically (by checking ?automatically connect at start-up? on the status tab of debugger>settings .) on connection, for dspic ? devices, silicon version information will be displayed in the output window. 2.6 setting up the environment this section provides a quick summary on mplab icd 2 operation. ? setting debugging and programming options ? creating and building a project 2.6.1 setting debugging and programming options the easiest way to set up the mplab icd 2 for operation is to use the mplab icd 2 setup wizard ( debugger>mplab icd 2 setup wizard .) additionally, these dialogs allow you to set or reset debugging and programming options: ? configuration bits dialog ( configure>configuration bits ) ? select the configuration bits on the picmicro processor. for complete details about these options, see the special features ? configuration bits section of the data sheet for the device being programmed. note: configuration bits can be specified in the source code instead of setting them in this dialog. when doing this, every time the project is rebuilt, the configuration bits will get reset to the values specified in the source code. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
getting started ? 2005 microchip technology inc. DS51331B-page 35 ? icd settings dialog ( debugger>settings or programmer>settings ) ? set up communications, power, pro- gramming and warning message output, as well as view status, limitations and version information. you have previously used the communications and power tabs when setting up the mplab icd 2 hardware. the follow- ing tabs are useful for completing the icd setup. for detailed information on these and the other tabs on the settings dialog, see section 5.4 ?settings dialog? . - program tab ? set up programming options (select memories, program and external memory ranges, id and program options, erase all). if programming the id bits is desired, set the value to be programmed in the configure>id memory dialog. - warning tab ? determine which warning messages will be displayed. can be useful to select messages if they are to be outputted to a file (see status tab.) - status tab ? in addition to autoconnect on startup and self-test control, output messages may be selected to be logged to a file. these messages may assist users or, if necessary, microchip technical support in finding errors. 2.6.2 creating and building a project the easiest way to create a new project is to select project>project wizard . with the help of the project wizard, a new project and the language tools for building that project can be created. the wizard will guide you through the process of adding source files, libraries, linker scri pts, etc. to the various ?nodes? on the project window. see mplab ide documentation for detailed steps on using this wizard. after the project is created, choose project>build all to build the application. this will create objec t code for the application that can be programmed into the target with mplab icd 2. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 36 ? 2005 microchip technology mplab ? icd 2 user?s guide 2.7 mplab icd 2 development process the development process with mplab icd 2 consists of these steps: 1. programming the target processor for debugging. 2. debugging the application. 3. modifying target application code and rebuilding the hex file. 4. finishing the application: using mplab icd 2 as a programmer. 5. additional programming options. 2.7.1 programming the target processor for debugging to program the application project?s code into the mplab icd 2 for debugging, follow these steps: 1. select debugger>settings and then click the program tab to set the programming options for your application. 2. select configure>configuration bits and set the oscillator and other configuration bit settings appropriate to the target. 3. select debugger>program to download your code and debug executive to the device in the application or demo board that is connected to the mplab icd 2. download time will depend on the memory used (i.e., program memory, eeprom), size of program and voltage. 2.7.2 debugging the application to debug your code, you must execute (run) it. ? real-time execution ? breakpoints ? step mode execution ? writing data eeprom www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
getting started ? 2005 microchip technology inc. DS51331B-page 37 2.7.2.1 real-time execution real-time execution occurs when the device in the demo/application board is put in mplab ide's run mode. when the mplab icd 2 is run in real time, instructions execute just as the processor would wit hout the debugger. while in the run mode, register displays on the screen will not update. to execute the code in real-time: 1. open the source file (double click on the file name in the project window or use file>open ) or program memory window ( view>program memory ) for viewing. 2. select debugger>run (or click the toolbar run button). the processor will run until a breakpoint is reached or until the processor is halted by selecting debugger>halt (or clicking the toolbar halt button). 2.7.2.2 breakpoints breakpoints allow you to specify co nditional program halts so that you may observe memory, register or variable values after a run- time execution. you may set breakpoints in either the file (editor) window, the program memory wi ndow or the disassembly window. you may set a breakpoint using either: ? right-mouse button menu ? click on the line in code at which you wish to set a breakpoint and select set breakpoint. ? breakpoint dialog ? open the dialog and enter a breakpoint at a specific address breakpoints are a function of the mplab ide and discussed in more detail in documentation for that tool. note: for most devices, only one breakpoint will be set (active) at a time, although you may specify more than one breakpoint in the breakpoint dialog (i.e., one breakpoint will be active and the others will be inactive.) www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 38 ? 2005 microchip technology mplab ? icd 2 user?s guide advanced breakpoints are a function of the mplab icd 2. for more information, see section 5.6 ?advanced breakpoints dialog? . 2.7.2.3 step mode execution step mode execution can be accessed after the processor is halted. step mode execution occurs when you single step the processor or execute debugger>step into . step mode execution allows you to step through the code one instruction at a time, to watch the program flow, and to see the register contents at each instruction (as set in the dialog box). 2.7.2.4 writing data eeprom if data eeprom is written during program execution, the eeprom window of mplab ide will not reflect the changes. you will need to perform a read of eeprom memory in order to update the values in the window. if some register or memory values do not seem correct in other windows, remember that mplab icd 2 has reserved resources. 2.7.3 modifying target application code and rebuilding the hex file to modify the code and rebuild the hex file: 1. open the source file (double click on the file name in the project window or use file>open ). 2. make the necessary changes to debug the code. 3. rebuild the hex file using project>build all . 4. select debugger>program to program the device with the updated hex file. note: while single stepping, the mplab icd 2 will not respond to interrupts. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
getting started ? 2005 microchip technology inc. DS51331B-page 39 2.7.4 finishing the application: using mplab icd 2 as a programmer once the code has been debugged and the application is running as designed, the device can be programmed without the debugger enabled. the device resources reserved for icd operation then will be free for other use. to change mplab icd 2 mode from debug to program: 1. set the debugger to ?none? from the debugger>select tool menu. 2. select programmer>select programmer>mplab icd 2 to choose mplab icd 2 as a programmer. the programmer menu and mplab ide toolbar will change to display pro- grammer options once the tool is selected. also, the output window will open and messages concerning icd status and communications will be displayed on the mplab icd 2 tab. the project should rebuild now so that all debugging modes will be disabled and the configuration bits as defined in the source code will be programmed into the target. to program the application project?s code into the device, follow these steps: 1. select programmer>settings and then click the program tab to set the programming options for your application. note: mplab icd 2 may be selected as either a debug tool or a programmer. do not select both. note: if you are using the universal programming module (upm), mplab icd 2 must be powered with a power supply to be used as a programmer. also, the option ?power target circuit from mplab icd 2? on the power tab of programmer>settings must be checked. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 40 ? 2005 microchip technology mplab ? icd 2 user?s guide 2. configuration bits will be set as defined in the source files. to set manually, select configure>configuration bits and set the oscillator and other configuration bit settings appropriate to the target. 3. if desired, set the id bits by selecting configure>id memory . 4. select programmer>blank check to check that the device is blank/has been erased and is ready to program. 5. select programmer>program to download your code to the device in the application or demo board that is connected to the mplab icd 2. download time will depend on the memory used (i.e., program memory, eeprom), size of program and voltage. 2.7.5 additional programming options as a programmer, mplab icd 2 has several other programmer functions besides simply programming the target device. 2.7.5.1 verifying the programming select verify from the programmer menu or toolbar to verify that the device was programmed correctly based on the hex code in mplab ide memory and the settings on the program tab of the settings dialog. 2.7.5.2 reading a device select read from the programmer menu or toolbar to read the device memory, based on the settings on the program tab of the settings dialog, into mplab ide memory. memory read from a device into mplab ide memory may then be saved to a file. the type of file saved will depend on the type of memory read. if you attempt to read a code-protected device, you will get a warning indicating that the device is code-protected and that the program memory may be invalid. if this happens, obtain the original hex code from a file or a non-protected device. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
getting started ? 2005 microchip technology inc. DS51331B-page 41 2.7.5.3 erase/blank check a device from the programmer menu or toolbar, select the following items to erase and then blank check a device: ? erase device ? select erase to erase the device memory. ? blank check ? select blank check to verify that the device is erased/blank. note: internal oscillator and bandgap calibration bits are always preserved by mplab icd 2, for the erase cycle. only during programming may their values be changed. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 42 ? 2005 microchip technology mplab ? icd 2 user?s guide notes: www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
? 2005 microchip technology inc. DS51331B-page 43 mplab ? icd 2 user?s guide chapter 3. mplab icd 2 tutorial 3.1 introduction this tutorial walks you through t he process of developing a simple project using the sample program, tut452.asm , found in the directory c:\program file s\microchip\mpasm suite\example . this program is an implementation of the pic18f452 analog-to-digital (a/d) converter using the picdem? 2 plus demo board (dm163022). the program configures the a/d module to convert input from a/d channel 0 (connected to the potentiometer on the demo board) and display the results on the four portb leds (rb3:rb0). topics covered in this chapter: ? setting up the environment ? running the project wizard ? viewing the project ? creating a hex file ? setting debug options ? setting up the demo board ? loading program code for debugging ? running tut452 ? debugging tut452 ? programming the application ? tut452 main routine and source code www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 44 ? 2005 microchip technology mplab ? icd 2 user?s guide 3.2 setting up the environment before beginning this tutorial, follow the steps in chapter 2. ?getting started? to set up the hardware and mplab ide software. some of the initial setti ngs covered in this tutorial may already be in place as a result of the previous set up. once launched, the mplab ide desktop should appear. figure 3-1: mplab ? ide www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab icd 2 tutorial ? 2005 microchip technology inc. DS51331B-page 45 3.2.1 selecting the device and development mode to select the device for this tutorial: 1. select configure>select device . 2. in the device selection dialog, choose pic18f452 from the device list box. the ?light? icon next to mplab icd 2 in the microchip tool support section should be green. 3. click ok . to select mplab icd 2 as a debugger: 1. select debugger>select tool>mplab icd 2 . the debugger menu will then show the other debug options available. also, the output window will open to display connection information. 2. select debugger>mplab icd 2 setup wizard to set up icd operation: a) select a port ? com or usb b) select target power supply c) enable auto-connection feature d) enable automatic os download feature e) for romless devices, set up external memory 3. select debugger>connect to connect to the mplab icd 2. note: if mplab ide attempts to connect on start up to the mplab icd 2 but fails because a usb port or a com port other than com1 is being used, allow the connection to fail. the communications port will be setup in the next step. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 46 ? 2005 microchip technology mplab ? icd 2 user?s guide 3.2.2 updating mplab icd 2 firmware (operating system) depending on the version of mplab ide or the device selected, a message may appear indicating that the firmware needs to be updated. mplab ide will automatically install new firmware. the update dialog may look like this: figure 3-2: updating mplab ? icd 2 firmware dialog also, since different mplab icd 2 firmware is used for different families of devices, this dialog may appear when switching to a different device. the firmware can be manually changed by following the steps in section 4.2 ?upgrading the mplab icd 2 firmware (operating system)? . www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab icd 2 tutorial ? 2005 microchip technology inc. DS51331B-page 47 3.3 running the project wizard the mpasm? assembler will be used in this project. 1. to set up the first project, select project>project wizard . 2. proceed to the second dialog of the wizard. the pic18f452 should be selected. 3. proceed to the next dialog of the wizard to set up mpasm assembler as the language tool. in the ?active toolsuite? pull-down, select ?microchip mpasm toolsuite.? make sure that the tools are set to the proper executables, by default located in the directory c:\program files\ microchip\mpasm suite . mpasm assembler should be pointing to mpasmwin.exe , mplink? linker should be pointing to mplink.exe and mplib? librarian should be pointing to mplib.exe . figure 3-3: wizard toolsuite dialog 4. proceed to the next dialog of the wizard to give a name and location to your project. you may browse to find a location. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 48 ? 2005 microchip technology mplab ? icd 2 user?s guide 5. proceed to the next dialog of the wizard where project files can be added. files can also be added later if something is missed. for this example, go to c:\program files\ microchip\mpasm suite\ example\tut452.asm . click on tut452.asm to highlight it, then click on add>> to add it to the right pane. then click in the checkbox next to the file in this pane to copy it into the project directory. figure 3-4: wizard add files www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab icd 2 tutorial ? 2005 microchip technology inc. DS51331B-page 49 6. the second file needed for this project is the linker script. click on the c:\program file s\microchip\mpasm suite\lkr folder to expand it, and then scroll down to select the file 18f452i.lkr . make sure that the file name has an ? i .? press add>> to move the linker script to the list on the right. you will not be copying this file into the project directory. figure 3-5: wizard add files ? linker script 7. proceed to the summary screen. if you have made any errors, click DS51331B-page 50 ? 2005 microchip technology mplab ? icd 2 user?s guide 3.4 viewing the project after exiting the wizard, the mplab ide desktop will again be visible. close all other windows on the desktop to see the project window. figure 3-6: project window additional files can be added to the project using the project window. right-click on any line in the project window tree to pop up a menu with additional options for adding and removing files. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab icd 2 tutorial ? 2005 microchip technology inc. DS51331B-page 51 3.5 creating a hex file to create a hex file for debugging, select project>build all or right- click on the project name in the project window and select ?build all? from the popup menu. mpasm assembler always makes a .hex file with the same name as the source .asm file. figure 3-7: output window www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 52 ? 2005 microchip technology mplab ? icd 2 user?s guide 3.6 setting debug options before you begin debugging your code, you will need to set up or check the default settings of several items. 3.6.1 configuration bits to set configuration bits to be programmed into the device, select configure>configuration bits . by clicking on the text in the ?settings? column, these can be changed. in this dialog, the following configuration bits should be set for this tutorial: ? oscillator ? ec-os2 as ra6 (this is for picdem 2 plus, if using another target, change to match) ? osc switch enable ? disabled ? power-up timer ? enabled ? brown-out detect ? disabled ? watchdog timer ? disabled ? ccp2 mux ? rc1 ? stack overflow reset ? disabled ? low voltage programming ? disabled ? all other configuration bits should be disabled. 3.6.2 programming options to set program options, select debugger>settings and click on the program tab. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab icd 2 tutorial ? 2005 microchip technology inc. DS51331B-page 53 figure 3-8: mplab ? icd 2 settings dialog, program tab ? the ?memories? section should have ?program? checked, and ?eeprom? and ?id? unchecked. when using mplab icd 2 as a debugger, configuration bits will always be programmed and the ?configuration? box w ill be checked and grayed out. ? for the pic18fxx2 devices, all memory will be erased each time the chip is programmed. therefore, in the ?program options? section, ?erase all before program? will have no effect. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 54 ? 2005 microchip technology mplab ? icd 2 user?s guide ? the ?program memory? addresses (?start? and ?end? address) set the range of program memory that will be read, programmed or verified. click full range to set the address range to the maximum program memory available based on the device selected. the end of program memory is adjusted to leave room for the mplab icd 2 debug executive. programs cannot extend beyond this upper limit while using mplab icd 2 as a debugger. 3.7 setting up the demo board before beginning to debug, make sure the picdem 2 plus demo board is set up as follows: ? ec osc option has been selected using jumper j7 ? leds have been enabled using jumper j6 ? power is supplied 3.8 loading program code for debugging select debugger>program to program tut452.hex into the pic18f452 in the picdem 2 plus demo board. programming may take a couple of minutes. during programming, the mplab icd 2 tab of the output dialog shows the current phase of operation. when programming is complete, the dialog should look similar to figure 3-9. note: the debug executive code is automatically programmed in upper program memory for mplab icd 2 debug functions. debug code must be programmed into the target picmicro mcu to use the in-circuit debugging capabilities of the mplab icd 2. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab icd 2 tutorial ? 2005 microchip technology inc. DS51331B-page 55 figure 3-9: output window ? mplab ? icd 2 tab 3.9 running tut452 mplab icd 2 executes in real-time or in step mode. ? real time execution occurs when the pic18f452 in the picdem 2 plus demo board is put in the mplab ide?s run mode. ? step mode execution can be accessed after the processor is halted. these toolbar buttons can be used for quick access to commonly used debug operations. debugger menu toolbar buttons run halt animate step into step over step out reset www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 56 ? 2005 microchip technology mplab ? icd 2 user?s guide begin in real-time mode: 1. open the tut452.asm file (double click on the file name in the project window or use file>open ). 2. select debugger>run (or click the run toolbar button). 3. on the demo board, turn the arrow on the potentiometer (ra0). observe the leds. if the program were working correctly, the user would see a binary representation of the voltage value across the potentiometer. however, there is a bug in the tut452 program. section 3.10 ?debugging tut452? will detail debugging the code and correcting it. 4. select debugger>halt (or click the halt toolbar button) to stop the program execution. 5. select debugger>reset to reset the program. 3.10 debugging tut452 any of the following can prevent the tut452 program from working. ? the a/d converter value is not being properly written to portb (leds). ? the a/d converter is not on or has not been set to convert. ? a typing error in the source code is causing the program to function improperly. to explore the first possibility, set a breakpoint at the line of the file that writes the value of a/d result to portb. 1. highlight or place the cursor on the following line of code from tut452.asm : movwf portb ;write a/d result to portb 2. right-click to display a shortcut menu. 3. select set breakpoint from the shortcut menu. this line is now marked as a breakpoint (b in red stop sign) as shown in figure 3-10. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab icd 2 tutorial ? 2005 microchip technology inc. DS51331B-page 57 figure 3-10: set breakpoint 4. select debugger>run (or click the run toolbar button) to run the program once again in real-time mode. a breakpoint stops a program?s execution when the program executes the line marked as a breakpoint. however, the sample program is not halting. 5. select debugger>halt (or click the halt button on the toolbar) to halt the program now. in the source code window, the sample program will have halted on one of the two lines in the wait routine as shown in figure 3-11 (at the arrow). www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 58 ? 2005 microchip technology mplab ? icd 2 user?s guide figure 3-11: program halted based on the halt location and the fact that the program never reaches the breakpoint, it can be concluded that the problem is in the a/d conversion. the a/d flag for conversion complete is not being set. a/d conversion initialization and setup occurs at the beginning of the program. 6. to reset the program, select debugger>reset . the first instruction should be indicated with a green arrow. 7. open a new watch window to watch the a/d register value change as the program executes. select view>watch . the watch dialog opens with the watch_1 tab selected. select ?adcon0? from the list next to add sfr, and then click the button. adcon0 is added to the watch window. repeat for adcon1. the selected symbols should now be visible in the watch window as shown in figure 3-12. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab icd 2 tutorial ? 2005 microchip technology inc. DS51331B-page 59 figure 3-12: watch window 8. in the tut452.asm source code, set a breakpoint at the first instruction after start. highlight or place the cursor in the following line of code from tut452.asm : clrf portb ;clear portb right-click to display a shortcut menu. select set breakpoint from the shortcut menu. this line will now be marked as a breakpoint. 9. select debugger>run (or click the run toolbar button) to run the program in real-time mode. this time the program will stop af ter it executes the breakpoint line of code and the instruction after the breakpoint will be indicated as shown in figure 3-13. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 60 ? 2005 microchip technology mplab ? icd 2 user?s guide figure 3-13: program halted after break 10. single step five times, select debugger>step (or click the step toolbar button) to single step through the program. the following line of code should be indicated when finished: movlw b'11000111' ;tm r0 prescaler, 1:256 11. examine the values of the registers adcon0 and adcon1 in the watch window. notice that adcon0 has a value of 40 hex. this corresponds to the binary value designated in the program, but is this value correct? a review of the pic18f452 data sheet (ds39564) section on a/d, indicates that the last bit should be a one, not a zero, to turn the a/d module on. to fix this bug, change: movlw b'0100000 0 ';fosc/8, a/d enabled to: movlw b'0100000 1 ';fosc/8, a/d enabled 12. select file>save to save the changes. 13. select project>build all to rebuild the project. a message will indicate that the program has been rebuilt. the mplab icd 2 must be reprogrammed for the changes to take effect. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab icd 2 tutorial ? 2005 microchip technology inc. DS51331B-page 61 14. select debugger>program to reprogram the mplab icd 2 with the changes. when the mplab icd 2 dialog indicates ?...programming succeeded?, the program is ready to run again. 15. right-click on the line of code that previously had the breakpoint (now indicated by a red stop sign outline). select remove breakpoint . 16. select debugger>run (or click the run toolbar button) to run the program in real-time mode. turn the potentiometer (ra0) to change the value displayed on the leds. the source code in this tutorial contained only one bug. however, real code may have more. using the mplab icd 2 and mplab ide debugging functions, users can successfully find and fix the problems in their code. 3.11 programming the application when the program is successfully debugged and running, usually the next step is to program the picmicro mcu for stand alone operation in the finished design. when doing this, the resources reserved by the icd are released for use by the application. to program the application follow these steps: 1. disable mplab icd 2 as a debug tool by selecting debugger>select tool>none . 2. select mplab icd 2 as the programmer in programmer>select tool menu. 3. optional: set up the id in configure>id memory (figure 3-14). www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 62 ? 2005 microchip technology mplab ? icd 2 user?s guide figure 3-14: user id memory dialog 4. set up the parameters for programming on the programmer>settings program tab. 5. select programmer>program . now mplab icd 2 can reset and run the target (mplab icd 2 can also be disconnected from the target; after selecting the reset button, the application will run). 3.12 tut452 main routine and source code the main routine of tut452.asm (figure 3-14) begins by configuring portb, the a/d module and timer0. it then waits for a timer0 overflow to start the a/d conversion of the value from the potentiometer. when the conversion is complete, the value is displayed on the leds, and the program loops back to wait for another timer0 overflow to start another a/d conversion. for more information on a/d module operation and a list of related application notes, refer to the picmicro ? 18c mcu family reference manual (ds39500). www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab icd 2 tutorial ? 2005 microchip technology inc. DS51331B-page 63 figure 3-15: tut452 main routine flow start configure portb as all outputs configure a/d left justify, f osc /8 clock 1 analog channel configure timer0 prescaler assigned to timer0 1:256 prescale timer0 overflow? no yes start a/d conversion conversion no yes complete? write a/d result to portb www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 64 ? 2005 microchip technology mplab ? icd 2 user?s guide ;******************** ******************** ;* tut45 2.asm * ;******************** ******************** list p=18f452 include "p18f452.inc" reset_vector ;put a goto at code 0x0 ;reset address goto start start code 0x0002a ; start app beyond ;vector area clrf portb ;clear portb clrf trisb ;portb all outputs, ;display 4 msb's of a/d ;result on leds movlw b'01000000' ;fosc/8, ;a/d enabled movwf adcon0 movlw b'00001110' ;left justify, ;1 analog channel movwf adcon1 ;vdd and vss ref?s movlw b'11000111' ;tmr 0 prescaler,1:256 movwf t0con main btfss intcon,tmr0if ;wait for timer0 ;to timeout goto main bcf intcon,tmr0if bsf adcon0,go ;start a/d ;conversion www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab icd 2 tutorial ? 2005 microchip technology inc. DS51331B-page 65 wait btfss pir1,adif ;wait for conversion goto wait ;to complete swapf adresh,w ;swap a/d result nibbles andlw 0x0f ;mask off lower 4 bits movwf portb ;write a/d result ;to portb clrf portb waitpush ;pause while switch btfss porta,4 ;is pressed goto waitpush movwf portb goto main ;do it again end www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 66 ? 2005 microchip technology mplab ? icd 2 user?s guide notes: www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
? 2005 microchip technology inc. DS51331B-page 67 mplab ? icd 2 user?s guide chapter 4. advanced usage 4.1 introduction as you work with mplab icd 2 to develop your application, these are some additional topics that you may find useful. topics covered in this chapter are: ? upgrading the mplab icd 2 firmware (operating system) ? creating/loading a hex file ? special linker script files ? romless device considerations ? special icd devices 4.2 upgrading the mplab icd 2 firmware (operating system) by default, mplab ide will automatically download the correct and most up-to-date operating system for your selected device to the mplab icd 2. this feature is selected from the settings dialog, status tab, by checking the checkbox ?automatically download firmware if needed?. if you have unchecked this checkbox, you may manually download the operating system (not recommended) as follows: 1. select debugger>download icd2 operating system or programmer>download icd2 operating system . the select icd firmware file dialog will open. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 68 ? 2005 microchip technology mplab ? icd 2 user?s guide 2. select the firmware file to download from the list or browse for it. the file will be of the form icdxxxxxx.hex , where xxxxxx is the version number. see the readme file for information on which file supports which devices. 3. click open . mplab ide will download the new operating system to the mplab icd 2. 4.3 creating/loading a hex file once the hex file is created/im ported, you can use mplab icd 2 to debug and/or program your code. 4.3.1 creating a hex file if you need to create your hex code, mplab ide offers a complete development environment. to create a hex file in mplab ide: ? set up a project and related workspace to develop your application. for information on using projects and workspaces, please see mplab ide help. ? use mplab editor to create or import source code. ? use language tools specified under the project menu to assemble/compile your source code into hex code. 4.3.2 loading a hex file if you already have a hex code file that you would like to program into your device, (i.e., you have used a tool other than the mplab ide to generate your hex code), you may load the hex code to mplab ide. to load a hex file into mplab ide: ? use the file>import command. note: if the wrong firmware is selected, mplab icd 2 will experience unknown errors. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
advanced usage ? 2005 microchip technology inc. DS51331B-page 69 4.3.3 hex file requirements whatever tool you use to develop your hex code, please keep in mind the following: ? your code should be limited depending on the device because a portion of program memory on the device is reserved. ? the start of eeprom data memory needs to be specified. for most picmicro mcu?s, the start should be at 0x2100 (org h?2100?). for pic18fxxxx devices, the start should be at 0xf00000 (org h?f00000?). please check the programming specification for your selected device to determine the correct address. 4.4 special linker script files mplab ide provides separate linker script files that reserve the resources used by the mplab icd 2. there is a separate linker file for each supported device. the filenames contain the name of the device, followed by an ? i ?. examples: ? 18f452i.lkr ? for the pic18f452 device ? 18f4580i_e.lkr ? for the pic18f4580 device with extended memory customers that are using the mplab icd 2 should use the linker file supplied for the device they are programming, instead of the standard linker files. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 70 ? 2005 microchip technology mplab ? icd 2 user?s guide 4.5 romless device considerations working with romless (no on-chip program memory) devices is different from working with regular devices. you must create the routines that read/write memory. for more information, please see: ? implementing the external memory interface on pic18c601/801 application note (an778) 4.5.1 picdem 18r there is a microchip demonstration board, picdem 18r, avail- able for development using romless devices. even if you do not purchase the demo board kit (d m163006), you can download the software and documentation for free from the microchip web site and use it to help you develop your own code: ? picdem 18r demonstration board user?s guide (ds39565) ? picdem 18r schematics ? picdem 18r software mplab ide contains files that may be used with mplab icd 2 and picdem 18r in the \icd2 subdirectory when mapping external memory for romless devices. 4.5.2 additional reference documents ? pic18c601/801 datasheet (ds39541) ? pic18cxxx otp in-circuit serial programming (ds39028) ? pic18xxxx mcu family product overview (ds30327) www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
advanced usage ? 2005 microchip technology inc. DS51331B-page 71 4.5.3 external memory this section only applies to romless (pic18c601/801) devices. 4.5.4 picdem 18r files there is a folder called \icd2 that was copied into the mplab ide installation directory. this folder has two files which can be used with the picdem 18r demo board (dm163006): ? sram16.hex ? allows program download to the static ram ? 29f16016.hex ? allows program download to the flash memory file click the browse button to select t he location of the writeprogramword and er aseprogrammemory files. see picdem 18r files. you must use a different memory routine file for the 8-bit bus width and the 16-bit bus width devices. the memory routine files mu st match the following naming conventions: . where does not exceed 8 characters. valid 16-bit filename examples: 29f16016.hex sram16.hex valid 8-bit filename examples: 29f16008.hex sram08.hex see the \icd801\source folder for information on writing your custom routines. these code routines will be used to program memory. they must be relocatable and comply with the format used in the included source files. use default pro- gram routines select this option to use the default memory routines provided with mplab ide in stead of providing your own memory routines. see picdem 18r files. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 72 ? 2005 microchip technology mplab ? icd 2 user?s guide when using picdem 18r, you must use one of the above files in the ?location of writeprogramword and eraseprogrammemory? dialog on the mplab icd 2 advanced dialog. also, you must remember to do an erase before programming as this is not done automatically. for your own design, which probably has different programming algorithms for the memory on your target, you must substitute your own memory read/write routine in order for the mplab icd 2 to download code. see the picdem 18r documentation for informa- tion on writing your custom routines. these code routines will be used to program your memory and care must be taken to ensure they are relocatable and comply with the format used in the included source files. 4.6 special icd devices some devices have special icd versions (e.g., pic12f629-icd for the pic12f629) to limit the number of device resources that must be used for debugging. only the icd version of the device may be used for debugging; the actual device does not have the built-in circuitry necessary to work with mplab icd 2. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
? 2005 microchip technology inc. DS51331B-page 73 mplab ? icd 2 user?s guide chapter 5. icd function summary 5.1 introduction when you select mplab icd 2 from the debugger menu, debug- ging functions will be added to mplab ide. when you select mplab icd 2 from the programmer menu, pro- gramming functions will be added to mplab ide. the functions made available are summarized here. mplab icd 2 functions are added to mplab ide as follows: ? debugging functions ? programming functions ? settings dialog ?setup wizard ? advanced breakpoints dialog 5.2 debugging functions when you select mplab icd 2 from the debugger menu, debug items will be added to the following mplab ide functions: ? debugger menu ? toolbars ? right mouse button menus www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 74 ? 2005 microchip technology mplab ? icd 2 user?s guide 5.2.1 debugger menu run f9 execute program code until a breakpoint is encountered or until halt is selected. execution starts at the current program counter (as displayed in the status bar). the current program counter location is also represented as a pointer in the program memory window. while the program is running, several other functions are disabled. animate animate causes the debugger to actually execute single steps while running, updating the values of the registers as it runs. animate runs slower than the run function, but allows you to view changing register values in the special function register window or in the watch window. to halt animate, use the menu option debugger>halt instead of the toolbar halt or f5 . halt f5 halt (stop) the execution of program code. when you click halt, status information is updated. step into f7 single step through program code. for assembly code, this command executes one instruction (single or multiple cycle instructions) and then halts. after execution of one instruction, all the windows are updated. for c code, this command executes one line of c code, which may mean the execution of one or more assembly instruction, and then halts. after execution, all the windows are updated. step over f8 not available on mplab icd 2. performs the same as step into. note: do not step into a sleep instruction. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
icd function summary ? 2005 microchip technology inc. DS51331B-page 75 step out not available on mplab icd 2. reset f6 issue a reset sequence to the target processor. this issues a mclr to reset the program counter to the reset vector. if the processor is running it will cont inue running from the reset vector address. breakpoints f2 open the breakpoint dialog. set multiple breakpoints in this dialog; however, only one breakpoint is enabled at a time. advanced breakpoints open the advanced breakpoint dialog. setup advanced breakpoint features for devices that support this icd feature. mplab icd 2 setup wizard launch the wizard to help you set up the mplab icd 2. program download the debug executive module (if selected in program tab) and your code to the target device. read read target memory. information uploaded to mplab ide. abort operation abort any programming operation (e.g., program, read, etc.) terminating an operation will leave the device in an unknown state. connect establish communications between the mplab icd 2 and pc. download icd2 operating system download mplab icd 2 operating system. note: you may also right-click on a line of code to set a breakpoint. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 76 ? 2005 microchip technology mplab ? icd 2 user?s guide settings opens the mplab icd 2 settings dialog. set up communication, output file, power and program options. also, find out information about the current system configuration and device limitations. 5.2.2 toolbars when the mplab icd 2 is selected as a debugger, these toolbars are displayed in mplab ide: ? standard debug toolbar (run, halt, step into, step over, reset). see mplab ide help for more information. ? mplab icd 2 debug toolbar (program target device, read target device, reset and connect to icd). 5.2.3 right mouse button menus the following will appear on the right mouse menus in code displays, such as program memory and source code files: set/remove breakpoint set or remove a breakpoint at the currently selected line. enable/disable breakpoint enable or disable a breakpoint at the currently selected line. breakpoints remove, enable or disable all breakpoints. run to cursor run the program to the current cursor location. formerly run to here. set pc at cursor set the program counter (pc) to the cursor location. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
icd function summary ? 2005 microchip technology inc. DS51331B-page 77 5.3 programming functions when you select mplab icd 2 from the programmer menu, program items will be added to the following mplab ide functions: ? programmer menu ? toolbar 5.3.1 programmer menu mplab icd 2 setup wizard launch the icd setup wizard. program program specified memory areas: program memory, configuration bits, id locations and/or eeprom data. read read specified memory areas: program memory, configuration bits, id locations and/or eeprom data. verify verify programming of specifi ed memory areas: program memory, configuration bits, id locations and/or eeprom data. erase part erase all data on the picmicro mcu device including memory, id and configuration bits. blank check check to see that all device memory is erased/blank. release from reset set mclr to v dd . hold in reset set mclr to ground (zero.) www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 78 ? 2005 microchip technology mplab ? icd 2 user?s guide abort operation abort any programming operation (e.g., program, read, etc.) terminating an operation will leave the device in an unknown state. connect establish communications between the icd and pc. download icd2 operating system download icd operating system. settings opens the icd programmer dialog. set up communication, output file, power and program options. also, find out information about the current system configuration and device limitations. 5.3.2 toolbar program target device program specified memory areas: program memory, configuration bits, id locations and/or eeprom data. read target device read specified memory areas: program memory, configuration bits, id locations and/or eeprom data. verify target device memory verify programming of specified memory areas: program memory, configuration bits, id locations and/or eeprom data. erase target device erase all data on the picmicro mcu device including memory, id and configuration bits. verify target device is erased check to see that all device memory is erased/blank. reset and connect to icd establish communications between the icd and pc. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
icd function summary ? 2005 microchip technology inc. DS51331B-page 79 5.4 settings dialog select either debugger>settings or programmer>settings to open the settings dialog and set up the mplab icd 2. ? status tab ? communication tab ? limitations tab ? power tab ? program tab ? versions tab ? warnings tab 5.4.1 status tab this tab of the icd programmer dialog allows you to set connection and message options. connect status connect status shows the current connection status. automatically connect at startup enable/disable autoconnect on startup between mplab ide and mplab icd 2. automatically download firmware if needed if checked, the correct firmware for the selected device will automatically be down- loaded to the mplab icd 2. if unchecked, you will be prompted be fore firmware is downloaded. messages output to debug file enable/dis able the outputting of messages to a file. self test run self test execute a self-test on the mplab icd 2. self test results the results of the self-test are displayed in ta r g e t v dd , module v pp , mclr gnd, mclr v dd and mclr v pp . www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 80 ? 2005 microchip technology mplab ? icd 2 user?s guide 5.4.2 communication tab this tab of the icd programmer dialog allows you to set how the mplab icd 2 and the pc communicate. 5.4.3 limitations tab this tab of the icd programmer dialog allows you to view mplab icd 2 limitations for your selected device. brief limitations are shown in the text box under the device. for more detailed limitations, click details . 5.4.4 power tab this tab of the icd programmer dialog allows you to view mplab icd 2 and target power parameters and set the mplab icd 2 to power the target. view values for target v dd , target v pp and mplab icd 2 v pp . if you know the values have changed since you opened the dialog, you may click update to see these values update immediately or wait for one of the conditions specified on the dialog. click in the checkbox to enable/dis able ?power target circuit from mplab icd 2 (5v v dd )?. com port select the com port (com1, com2, com3 or com4) for serial communications or usb for universal serial bu s communications. default: com1 baud rate the initial com port baud rate for mplab icd 2 communications is 19200. after communications have been established, you may wish to select the 57600 option for improved performance. if you have increased communication errors at this speed, change back to the default. default: 19200 www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
icd function summary ? 2005 microchip technology inc. DS51331B-page 81 5.4.5 program tab this tab of the icd programmer dialog allows you to set up debug/ programming options. ? allow icd to select memories and ranges ? mplab icd 2 uses your selected device and default settings to determine what to program. ? manually select memories and ranges ? you select the type and range of memory to program. table 5-1: manual selection options memories program check to program pr ogram memory into target. configuration check to program co nfiguration bits into target. note: this memory is always programmed when in debug mode. eeprom check to erase and then program eeprom memory on target. uncheck to erase eeprom memory on target. id check to program id memory into target. external check to program external memory into target. note: to select external, your device must support external memory and you must have enabled ?use external me mory? in the external memory settings dialog ( configure>external memory ). program options freeze on halt set/clear all per ipherals to freeze on halt. erase all before program check to erase all memory before programming begins. unless programming new or already erased devices, it is important to have this box checked. if not checked, the devic e is not erased and pro- gram code will be merged with the code already in the device. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 82 ? 2005 microchip technology mplab ? icd 2 user?s guide preserve eeprom on program check to keep eeprom memory on target from being overwritten on programming. target eeprom memory values are read into mplab ? ide, erased from the target and then written back to the target. uncheck to use eeprom checkbox functionality under memories. program memory start, end the starting and en ding hex address range in program memory for pr ogramming, reading, or verification. if you receive a programming error due to an incorrect end address, you need to perform a reconnect, correct the end address and program again. note: the address range does not apply to the erase function. the erase function will erase all data on the device. full range enter the full range of device program memory in hex. external memory start, end the starting and en ding hex address range in program memory for pr ogramming, reading, or verification. note: to select external, your device must sup- port external memory and you must have enabled ?use external memory? in the external memory settings dialog ( configure>external memory ). if you receive a programming error due to an incorrect end address, you need to perform a reconnect, correct the end address and program again. note: the address range does not apply to the erase function. the erase function will erase all data on the device. table 5-1: manual selection options (cont.) www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
icd function summary ? 2005 microchip technology inc. DS51331B-page 83 5.4.6 versions tab this tab of the icd programmer dialog allows you to view the version numbers for mplab icd 2 elements. 5.4.7 warnings tab this tab of the icd programmer dialog allows you to select which mplab icd 2 warning messages you wi sh to display in the output window. this is useful for disab ling warnings that you know you will ignore and do not want to view. click in the checkbox next to a warning in the list to alternately enable/disable the warning. checked is enabled; unchecked is disabled. full range enter the full range of device program memory in hex. table 5-2: bootloader options enter your own bootloader or brow se for the file in user memory routines. table 5-3: automatic options program after successful build if the project builds successfully (no errors), automatically program the device. run after successful program if the device programs successfully (no errors), run the program. mplab icd 2 version pc software dll version firmware icd operating system firmware type device type for firmware firmware version icd operating system version bootloader version icd bootloader version debug exec version debug executive module version table 5-1: manual selection options (cont.) www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 84 ? 2005 microchip technology mplab ? icd 2 user?s guide 5.5 setup wizard a setup wizard is available from debugger>mplab icd 2 setup wizard to help walk you through setting up your icd. ? setup wizard ? welcome ? setup wizard ? select a port ? setup wizard ? select target power ? setup wizard ? enable auto connect ? setup wizard ? enable automatic os download ? setup wizard ? external memory ? setup wizard ? summary 5.5.1 setup wizard ? welcome when you first select mplab icd 2 as a debugger or programmer, the mplab icd 2 setup wizard will open. follow the dialogs in the mplab icd 2 wizard to set up mplab icd 2 for use with mplab ide. click next to continue. 5.5.2 setup wizard ? select a port step 1: select a communications method ? select a communications port to which you will attach the icd. ? com port ? select either a serial port (com1-com4) or a usb port (usb). ? baud rate ? for a serial port, select a baud rate of 19200 or 57600. click next to continue. note: you may wish to try the hig her baud rate to see if you can communicate at this speed. if you experience errors, return to the lower baud rate. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
icd function summary ? 2005 microchip technology inc. DS51331B-page 85 5.5.3 setup wizard ? select target power step 2: select target power source ? choose from where the target board will get its power. ? target has own power supply ? the target board will use its own power supply. ? power target from the mplab icd 2 ? you may use the mplab icd 2 to power the target board as long as: - mplab icd 2 has a power supply (the usb cannot provide enough power for both the mplab icd 2 and a target board.) - target board power requirements are within what the mplab icd 2 provide. click next to continue. 5.5.4 setup wizard ? enable auto connect step 3: enable autoconnection ? set up mplab ide to automatically connect to mplab icd 2 on project start-up. ? mplab ide automatically connects to mplab icd 2 ? check to connect on project start-up. uncheck to connect manually, i.e., using debugger>connect . click next to continue. caution if there is a device other th an the mplab icd 2 on the port when you autoconnect, damage to that device may result. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 86 ? 2005 microchip technology mplab ? icd 2 user?s guide 5.5.5 setup wizard ? enable automatic os download step 4: enable autodownload of operating systems ? automatically download the correct os for the selected device. ? required operating system automatically downloaded to mplab icd 2 ? check to automatically download the correct os for your selected device. the os will be downloaded when mplab ide detects that the current mplab icd 2 operating system is not correct for the selected device or there is a newer version of this operating system. uncheck to be prompted to download the os. if you choose not to download the os, it may be downloaded manually later using debugger>download icd operating system . click next to continue. 5.5.6 setup wizard ? external memory step 5: specify amount of external memory ? specify the amount of external memory you will use for your romless device. the start address is always zero (0). enter an end address value in decimal or hex (use 0x before number.) click next to continue. note: there are different operating systems for different devices. note: downloading an incorrect operating system will cause unknown errors. it is recommended that you allow mplab ide to automatically download the os. note: this page will only appear if you have selected a romless device (pic18c601/801.) www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
icd function summary ? 2005 microchip technology inc. DS51331B-page 87 5.5.7 setup wizard ? summary check the summarized information. if anything is incorrect, use back to return to the dialog you need and change the information. click finish when you are satisfied with the mplab icd 2 setup. 5.6 advanced breakpoints dialog in addition to the basic breakpoints that you may set (right-mouse menu and standard breakpoint dialog), mplab icd 2 has an advanced breakpoints dialog ( debugger>advanced b reakpoints .) the options on the advanced breakpoint dialog are dependent on your selected device. ? pic18f devices ? regular pic18f mcu devices. ? extended pic18f devices v1 ? version 1 extended pic18f devices have an extended instruction set (available for mplab c18 c compiler use) that may be enabled through a configuration bit (xinst). ? extended pic18f devices v2 ? version 2 extended pic18f devices have the version 1 extended instruction set, as well as additional breakpoint capabilities. ? dspic devices ? dspic dsc devices. 5.6.1 pic18f devices the advanced breakpoints dialog for pic18f devices contains the following options. breakpoint is in program memory check this checkbox if the breakpoint will be located in program memory. then, enter the ?program memory address? as the location of the breakpoint. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 88 ? 2005 microchip technology mplab ? icd 2 user?s guide breakpoint is in file registers check this checkbox if the breakpoint will be located in data memory (file registers). then: ? read access/write access ? specify file register access. ? file register address ? enter location of breakpoint. ? file register value ? if ?file register must be equal to following value?, check the checkbox and then enter ?file register value?. additional breakpoint setup in addition to breakpoint memory setup, you may select the following: ? break on stack over/underflow ? break on stack overflow or underflow. ? pass count ? for the breakpoint set above, break for the entered pass count value (0-255). 5.6.2 extended pic18f devices v1 the advanced breakpoints dialog for extended pic18f devices (version 1) contains the following options. breakpoint number these devices support up to three breakpoints. enter a number and then set up that breakpoint below. change the number to set up another breakpoint. breakpoint is in program memory check this checkbox if the breakpoint will be located in program memory. then, enter the ?program memory address? as the location of the breakpoint. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
icd function summary ? 2005 microchip technology inc. DS51331B-page 89 breakpoint is in file registers check this checkbox if the breakpoint will be located in data memory (file registers). then: ? read access/write access ? spec ify file register access. ? file register address ? enter location of breakpoint. ? file register value ? if ?file register must be equal to following value?, check the checkbox and then enter ?file register value?. additional breakpoint setup in addition to breakpoint memory setup, you may select the following: ? break on stack over/underflow ? break on stack overflow or underflow. ? pass count ? for the breakpoint set above, break for the entered pass count value (0-255). 5.6.3 extended pic18f devices v2 the advanced breakpoints dialog for extended pic18f devices (version 2) contains the following options. 5.6.3.1 breakpoint parameters these options apply to the breakpoint specified in ?breakpoint #?. breakpoint number these devices support up to three breakpoints. enter a number and then set up that breakpoint below. change the number to set up another breakpoint. breakpoint is in program memory check this checkbox if the breakpoint will be located in program memory. then, enter the ?program memory address? as the location of the breakpoint. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 90 ? 2005 microchip technology mplab ? icd 2 user?s guide breakpoint is in file registers check this checkbox if the breakpoint will be located in data memory (file registers). then: ? read access/write access ? specify file register access. ? file register address ? enter location of breakpoint. ? file register value ? if ?file register must be equal to following value?, check the checkbox and then enter ?file register value?. additional breakpoint setup in addition to the above breakpoint setup, you may select the following at the bottom of the dialog: ? pass count ? for the breakpoint set above, break for the entered pass count value (0-255). 5.6.3.2 emulator features the following features apply i ndependent of the breakpoint setup above. event breakpoints for the breakpoint set above: ? break on stack over/underflow ? break on stack overflow or underflow. (future feature) ? break on watchdog timer ? break on a wdt time-out. (future feature) ? break on sleep ? break on a sleep instruction. the sleep instruction will not be executed. running or stepping from this point will execute the instruction after sleep. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
icd function summary ? 2005 microchip technology inc. DS51331B-page 91 enable stopwatch check to coordinate breakpoints with stopwatch operation. ? halt on start condition (breakpoint 2) - if checked, halt program (breakpoint 2 enabled) and program/stopwatch go on run. - if unchecked, program continues to run (breakpoint 2 disabled) and stopwatch is started. ? halt on stop condition (breakpoint 3) - if checked, halt program (breakpoint 3 enabled) and stopwatch. - if unchecked, program continues to run (breakpoint 3 disabled), but stopwatch halted. ? reset stopwatch on run ? any time you run the program, reset the stopwatch to zero. 5.6.4 dspic devices the advanced breakpoints dialog for dspic dsc devices contains the following options. breakpoint combinations this section is grayed out unless there are two breakpoints. the options are: ? both breakpoints must occur at the same time to cause a break. ? breakpoint 0/1 does not break until after breakpoint 1/0 occurs ? click swap bps to change the order. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 92 ? 2005 microchip technology mplab ? icd 2 user?s guide breakpoints breakpoint # select a breakpoint to set up, either 0 or 1. breakpoint type select the type of breakpoint. options below will change depending on the selection made here. disabled ? breakpoint disabled (default). other options grayed out. other selections ? see tables below. table 5-4: program memory breakpoint type program memory execution tblwt program memory tblrd program memory psv read program memory address enter the program memory address of the breakpoint. pass count type enter the pa ss count type, if desired. pass counting disabled ? default. event must occur pass count times. break occurs pass count instructions after event. pass count enter a pass count value, a number between 0 and 255. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
icd function summary ? 2005 microchip technology inc. DS51331B-page 93 table 5-5: data memory ? byte or word breakpoint type x bus write specific byte x bus read specific byte y bus read specific word x bus write specific word x bus read specific word data memory address enter the data memory address of the breakpoint. data value specify a value that the byte or word must be equal to before breaking. pass count type enter the pass count type, if desired. pass counting disabled ? default. event must occur pass count times. break occurs pass count instructions after event. pass count enter a pass count value, a number between 0 and 255. table 5-6: data memory breakpoint type y bus read x bus write x bus read data memory address enter the data memory address of the breakpoint. pass count type enter the pass count type, if desired. pass counting disabled ? default. event must occur pass count times. break occurs pass count instructions after event. pass count enter a pass count value, a number between 0 and 255. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 94 ? 2005 microchip technology mplab ? icd 2 user?s guide notes: www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
? 2005 microchip technology inc. DS51331B-page 95 mplab ? icd 2 user?s guide chapter 6. troubleshooting tips 6.1 introduction since many things in mplab ide, mplab icd 2 and the picmicro mcu target application circ uit can affect the operation of mplab icd 2, it is important to understand the operation of each link in the chain of icd functionality. figure 6-1 is a diagram showing the various links. each link must be functional for mplab icd 2 to program and debug. this section discusses these links to help find and fix problems if they occur. figure 6-1: chain of mplab ? icd 2 functionality pc to mplab icd 2 communication mplab icd 2 firmware mplab icd 2 to target picmicro mcu target power target osc in-circuit debug resources in-circuit debug registers debug executive application code www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 96 ? 2005 microchip technology mplab ? icd 2 user?s guide functional links are covered as follows: ? link: pc to icd communications ? link: icd firmware ? link: icd to target picmicro device ? link: target power ? link: target oscillator ? link: application code ? link: debug executive ? link: in-circuit debug registers ? link: in-circuit debug resources 6.2 link: pc to icd communications this link is the foundation for all subsequent links. if it doesn't work, mplab ide will issue communications errors. make sure that the mplab usb drivers are installed according to the instruc- tions. look at the windows hardware manager dialog under the usb section to see that the mplab icd 2 driver is properly installed on the pc. if using rs-232, make sure that the fifo buffers are turned off and flow control is set for hardware in the comm driver dialog. if the mplab ic d 2 usb driver is not visible in the usb section of the hardware manager, go to the mplab ide installation directory and open the \driversxxx folder ( xxx corresponds to the operating system, i.e., 98, nt, xp, etc.). open the .htm files with a web browser to view details on driver installation for the appropriate operating system. see section 2.3.1 ?setting up communications? for more information. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
troubleshooting tips ? 2005 microchip technology inc. DS51331B-page 97 6.3 link: icd firmware be sure that the latest version of firmware is loaded in the mplab icd 2. updated firmware can be downloaded with the mplab ide software. the latest production software should always be downloaded from the microchip web site. the version of firmware will determine which target picmicro mcus are supported. see the readme file for the latest information on the firmware and on mplab icd 2. 6.4 link: icd to target picmicro device verify that all lines are connected and that no other signals or components are interfering with icd signals on v pp , pgc and pgd. if mplab icd 2?s v dd and v ss lines are not connected to the target power and ground, it will not work. mplab icd 2 can provide v dd to the target (<200ma, 5 volts only) and to these output buffers when providing power to the target circuit (selected by the debugger>settings dialog power tab, ?power target circuit from mplab icd 2?). otherwise, the target?s v dd will be used. v dd is sensed by mplab icd 2 to check that voltage levels are correct. powering from the target v dd allows level translation for target low-voltage operation. a simplified circuit for the internal buffer circuits of mplab icd 2 is shown in figure 6-2. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 98 ? 2005 microchip technology mplab ? icd 2 user?s guide figure 6-2: mplab ? icd 2 internal buffer circuits if mplab icd 2 does not have voltage on its v dd line (pin 2 of the icd connector) it will not operat e. using a scope, communications on pgc and pgd with a full target v dd to v ss peak-to-peak waveform should be seen. v pp should show +12, +5 and 0v levels depending upon the operation being performed. signals should be seen on those lines only after performing an mplab icd 2 function from the mplab user inte rface. otherwise, all these lines should be idle and noise free. 6.5 link: target power mplab icd 2 can work within a range of about 2v to 5.5v on the target picmicro mcu?s v dd . the application must be powered by its own power supply. remember, that the pgc and pgd i/o drivers in mplab icd 2 are powered from the target v dd (see figure 6-2). 4.7k 4.7k ta r g e t v dd tv dd tv dd tv dd tv dd tv dd (to pin 2 of the icd connector) to pgc to pgd www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
troubleshooting tips ? 2005 microchip technology inc. DS51331B-page 99 6.6 link: target oscillator when programming a device, it will program without a running oscillator, but the debug function will not work unless the target oscillator is functioning. unlike an in-circuit emulator, while debugging, mplab icd 2 requires that the target picmicro mcu is running. testing may be necessary to make sure that the target system is executing instructions properly. for instance, a small program could be written to flash an led and then programmed into the target picmicro mcu with mplab icd 2 debug disabled. disconnect the icd and reset the target. if the led does not flash, check the circuitry to find out why it?s not operating. if mplab icd 2 is connected after programming the target with debug disabled, mplab can still toggle the reset. if it runs stand-alone but not with icd connected (after selecting debugger>run in the mplab ide), then the interconnections may be suspicious. use a scope to look at pgc, pgd and v pp . make sure that the oscillator starts up quickly. if it takes too long to get the target oscillator started, then mplab icd 2 can time out and give errors. make sure that the correct oscillator mode is selected (look at configure>configuration b its ). the oscillator mode will depend upon the oscillator selected. try hs mode for a crystal, and rc mode for an external resistor/capacitor oscillator. these settings may need to be changed for the final design, but they are some of the easiest modes to start with. oscillator operation can be checked on osc2 after configuration bits are set at programming time and power is applied in debug or normal mode. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 100 ? 2005 microchip technology mplab ? icd 2 user?s guide 6.7 link: application code verify that mplab icd 2 is programming properly by either running an led blink test similar to that described in link: target oscillator or by programming code into the target device. mplab icd 2 will execute a verify function after programming to confirm that the data in the target picmicro mcu matches the mplab icd 2 program memory. programmer>verify can also be selected manually to compare the target picmicro mcu?s memory with the mplab ide image. if the target picmicro mcu has av dd and av ss , ensure that they are connec ted properly. these lines should be connected to power (v dd ) and ground (v ss ) respectively. consult the device data sheet for details. mplab icd 2 will not operate if any of these are available and not connected. make sure that low voltage programming is disabled ( config ure> c onfiguration bits ). 6.8 link: debug executive when using the debugger>program function from mplab ide, the debug executive will be downloaded and the in-circuit debug registers in the target picmicro mcu will be enabled. program- ming should always be done from the debug menu, not the programmer menu when debugging. when programming from the programmer menu (after turning mplab icd 2 off as a debugger), the debug executive will not be downloaded and the in-circuit debug registers will be disabled. by looking at the config ure >configuration bits menu selection, it can be determined whether mplab is going to download the debug executive. if the bits labeled ?background debug? are enabled, then the debug execut ive will be downloaded when the device is programmed. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
troubleshooting tips ? 2005 microchip technology inc. DS51331B-page 101 6.9 link: in-circuit debug registers make sure that debug is enabled on the mplab icd 2 dialog in mplab ide before programming a device. by looking at the config ure > configuration bits dialog, it can be verified that the in-circuit debug registers are enabled. the line labeled ?back- ground debug? should say ?enabled.? programming should be done from the debug menu, not the programmer menu. 6.10 link: in-circuit debug resources look at the specific registers used for a device in the on-line help. the file registers or program memory areas reserved by mplab icd 2 can not be used. if using the xxxxxi.lkr linker script (name ends in ? i ?), then, unless the script has been modified, these resources will be marked reserved and will not be available to the application. if the linker is not being used, use cblock or equ s for variable storage in the code, make sure that registers required by mplab icd 2 are not used. the in-circuit debugger will not work if ?code protect? or ?table read protect? is enabled, if the watchdog timer is running or if the oscillator is not set to the correct mode by the configuration bits. if using fast interrupts or the call fast instruction, mplab icd 2 uses the shadow stack and users will not be able to exit properly from the fast interrupt routine or call fast function. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 102 ? 2005 microchip technology mplab ? icd 2 user?s guide notes: www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
? 2005 microchip technology inc. DS51331B-page 103 mplab ? icd 2 user?s guide chapter 7. self test 7.1 introduction the run self test button (settings dialog, status tab) is helpful in determining problems with the mplab icd 2 module or target connection. self test features covered are: ? target v dd ? module v pp ?mclr = gnd ?mclr = v dd ?mclr = v pp ? failed self test error ? v pp /v dd high/low 7.2 target v dd tests the v dd provided from the mplab icd 2 (5 volts only) if ?power target circuit from mplab icd 2? is selected. pass/fail codes: an error can indicate: ? target voltage/current mismatch from provided voltage/current ? mplab icd 2 pod hardware problems 0/0 = pass v dd is within specified limits 01 = min error v dd is below specified limits 80 = max error v dd is above specified limits www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 104 ? 2005 microchip technology mplab ? icd 2 user?s guide 7.3 module v pp tests the programming voltage (v pp ) provided from the mplab icd 2 to the target v pp /mclr pin during a programming cycle pass/fail codes: an error can indicate: ? the target v pp /mclr pin is not correctly wired 7.4 mclr = gnd test the ability of the mplab icd 2 to provide a ground level to the target v pp /mclr pin for target reset pass/fail codes: an error can indicate: ? the target v pp /mclr pin is not correctly wired 00 = pass v pp is within specified limits 01 = min error v pp is below specified limits 80 = max error v pp is above specified limits 00 = pass ground can be provided to target v pp /mclr pin 80 = max error ground leve l too high for target v pp /mclr pin www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
self test ? 2005 microchip technology inc. DS51331B-page 105 7.5 mclr = v dd test the ability of the mplab icd 2 to provide v dd to the target v pp /mclr pin during normal operation (such as run). pass/fail codes: an error can indicate: ? target voltage/current mismatch from provided voltage/current ? mplab icd 2 pod hardware problems 7.6 mclr = v pp test the ability of the mplab icd 2 to provide v pp to the target v pp /mclr pin during programming operations. pass/fail codes: an error can indicate: ?the target v pp /mclr pin is not correctly wired 00 = pass v dd can be provided to target v pp /mclr pin 01 = min error v dd too low for target v pp /mclr pin 80 = max error v dd too high for target v pp /mclr pin 00 = pass v pp can be provided to target v pp /mclr pin 01 = min error v pp too low for target v pp /mclr pin 80 = max error v pp too high for target v pp /mclr pin www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 106 ? 2005 microchip technology mplab ? icd 2 user?s guide 7.7 failed self test error ? v pp /v dd high/ low symptom: when connecting to the mplab icd2 in mplab ide or running a self-test ( debugger/programmer>settings>status>self test ), mplab ide may report a self-test error in the output window. cause: this could be due to the firmware routines used to determine minimum and maximum voltages (a less than compare is used in one place while a less-than or equal-to is used in another). solution: check the actual voltages measured by the icd. this can be found at programmer/debugger>settings>power . the update button will cause these voltages to be remeasured and displayed. as long as the voltages displayed are within tolerance for the target device, the mplab icd 2 unit can still be used for programming and debugging operations. the firmware will be changed for better support of self-test functions. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
? 2005 microchip technology inc. DS51331B-page 107 mplab ? icd 2 user?s guide chapter 8. general troubleshooting 8.1 introduction frequently asked questions (faqs) and common problems are documented here to help you as you use the mplab icd 2. also, messages generated by the icd and its tool limitations are referenced. topics covered in this chapter are: ? frequently asked questions ? common communication problems ? common problems ? error and warning messages ? limitations 8.2 frequently asked questions questions are listed in the order of most-to-least frequently asked. 8.2.1 q: why does my system fail to program or verify? a: check the pgc, pgd and v pp connections and voltages as described in chapter 2. ?getting started? . make sure the target picmicro mcu has power applied. if the target picmicro mcu has av ss and av dd pins, verify that these are all connected properly. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 108 ? 2005 microchip technology mplab ? icd 2 user?s guide 8.2.2 q: why do i need the icd header adapters ? a: the low pin count parts that are supported by mplab icd 2 could not be used very effectively if in-circuit debug pins are reserved ? imagine losing three out of six i/o lines on an eight-pin part! for this reason, specia l bond-out picmicro mcus have been manufactured that can emulate these low pin count parts with an adapter, and which will allow the use of all pins in the target application. the bond-out picmicro mcu has the in-circuit communications pins to interface to mplab icd 2. the advantage of this is that the low pin parts can be used in development with mplab icd 2. the disadvantage is that these parts cannot simply have an icd 2 connector on the target application for in-circuit debugging. these bond-out picmicro mcus are similar to emulator chips. they can support more than one device. jumpers are available on the header boards to con- figure the chip to match the device under development. these low pin count devices can be programmed with mplab icd 2 using the universal programmer adapter or by putting an icd 2 connec- tor on the target application to connect v pp , pgc and pgd on these parts. 8.2.3 q: i can't connect to mplab icd 2. what do i do now? a: is the mplab icd 2 power light on? the led should shine brightly. if it is dim, only usb may be connected and the user may need to connect the power supply. the rs-232 connection from the pc cannot supply power to mplab icd 2, but a usb connection can. note that some usb hubs cannot supply power. check the on-line help for current troubleshooting hints. are the usb drivers installed properly? the mplab icd 2 usb driver should be visible in the windows device manager dialog (see figure 8-1). some usb hubs cannot supply power to the attached usb devices. a power supply will need to be connected to mplab icd 2 with these hubs. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
general troubleshooting ? 2005 microchip technology inc. DS51331B-page 109 figure 8-1: system properties dialog 8.2.4 q: mplab icd 2 responds with ?target not in debug mode error.? what does this mean? a: usually this means that mplab icd 2 cannot communicate with the debug executive. the debug executive can only be downloaded by programming the target picmicro mcu with the user?s application from the debugger>program menu selection. there are other reasons that the debug executive might not be able to communicate, such as target clock or power supply problems. check the configuration bits to see that the ?background debug? is enabled. look at configure>configuration bits to make sure that the watchdog timer is disabled, code protection is turned off and that the oscillator setting is correct. 8.2.5 q: can mplab icd 2 operate with a target device running at low voltage? a: yes. as long as the target picmicro mcu supports low-voltage operation, it can run down to about 2 volts v dd . there are level converters in the input/output buffers of the mplab icd 2. these are powered from the v dd of the target device. also, mplab icd 2 will sense the operating voltage of the target and correctly adjust its functionality to deal with this operation, i.e., using the correct flash erase algorithms. v dd needs to be selected ?from target? in the mplab icd 2 ?settings? dialog, and have a power supply on the target for low-voltage operation. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 110 ? 2005 microchip technology mplab ? icd 2 user?s guide 8.2.6 q: does mplab icd 2 support low voltage programming (lvp)? a: no. but this does not mean that it will not work correctly when running at low-voltage v dd on the target. it just means that the programming voltages applied to v pp will always be +12v. 8.2.7 q: why do i have problems when configuring the pll oscillator? mplab icd 2 gets ?hung up.? a: this is a requirement of t he actual picmicro mcu. after programming the configuration bits for the pll oscillator, power needs to be removed then reapplied to the target. if this is not done, the target picmicro mcu will not have a clock. with no clock, debug mode will not function. also, if power is not removed and reconnected when switching to pll mode, the device may run, but without the pll multiplier. 8.2.8 q: when i try to install, why are the drivers not found, even though i can see them in the driver folders, and i point the driver wizard to the correct folder? a: this problem can be solved by exiting from the driver install wizard, and going to the control panel ?add new hardware? selection. after the system sear ches for new hardware, choose, ?no, the device isn?t in the list.? then choose ?no, i want to select the hardware from a list.? then choose ?universal serial bus controller,? and when the have disk... button appears, go to the driver folder and select the proper driver. 8.2.9 q: can i use code protection with mplab icd 2? a: no. code protection, especially table read protection on any area in program memory will prev ent mplab icd 2 from function- ing. do not use any code protection or table read protection configuration settings when d ebugging with mplab icd 2. code protection can be enabled when programming a part for testing without mplab icd 2. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
general troubleshooting ? 2005 microchip technology inc. DS51331B-page 111 8.2.10 q: how does mplab icd 2 deal with calibration data? a: it is automatically handled. any values that are in program memory that are used by the picmicro mcu for calibration data will be read and preserved by mplab icd 2 when erasing, programming and debugging. no action is required to protect this data. 8.2.11 q: why am i getting erratic values from my eedata area? a: mplab icd 2 can read the eedata areas directly, without going through the eecon register?s required tablrd sequence of instructions. the buffers that mplab uses can sometimes interfere with the user?s code. avoid going back and forth from program reads of data to mplab icd 2 reads of the eedata area when single stepping code. 8.2.12 q: why does my program keep resetting? a: check the configuration bits settings ( configure>configuration bits ) for your selected device. some reset functions (such as watchdog timer reset) are enabled by default. 8.2.13 q: why is ?erase all before programming? grayed out? a: in some of the newer flash parts, the programming algorithm requires that non-contiguous areas of program memory are programmed in banks. for these parts, all memory must be erased before programming. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 112 ? 2005 microchip technology mplab ? icd 2 user?s guide 8.2.14 q: can my program read and write from port b or gpio without interfering with mplab icd 2? a: yes. when the in-circuit debug facilities are enabled, pgc and pgd are always used by mplab icd 2, and user code that reads or writes from port b will not inte rfere. note that the values read from pgc and pgd are not necessarily valid, and writes to these two pins will be ignored. in addition, if interrupts are enabled for changes on port b, signals on pgc and pgd will not cause an interrupt. 8.2.15 q: why are the timers behaving erratically when single-stepping? a: this is one of the drawbacks of using the in-circuit debugger. since code is actually running in the debug executive, timers can continue to run during the operation of the debug executive, even when the user?s application program is ?halted.? 8.2.16 q: why am i getting warnings and errors when using the pic12f629/675 or pic16f630/ 676? a: the gp1/ra1 pins on these parts cannot be pulled high while using mplab icd 2. refer to the mplab icd 2 header document for more information on using icd 2 for these parts (ds51292). 8.2.17 q: what would make the power and busy led blink on and off ? a: this may indicate that the target mplab icd 2 connector is wired backwards (opposite from the wiring diagram). the blinking indicates that the mplab icd 2 is shutting down due to high current. the following tests indicate that the target is connected backwards: ? look for blinking power and busy leds (power may go out altogether). www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
general troubleshooting ? 2005 microchip technology inc. DS51331B-page 113 ? execute a ?self test? and look for a min. error on ?mclr =v pp ? (all other tests will probably pass). ? use the default address range for the target controller and execute a ?program? cycle. a voltage level on pin 1 (v pp ) of 7-8 volts is too low. if the target was wired backwards, protection circuitry in the mplab icd 2 will prevent damage to the module. normal operation should be seen when the target is wired correctly. 8.2.18 q: what does the mplab icd 2 ?self test? do? a: the mplab icd 2 self test is helpful in determining problems with the mplab icd 2 module or target connection. see chapter 7. ?self test? for more details. 8.2.19 q: why are the w, status and bsr registers getting changed when using high priority interrupts with the retfie instruction? a: the shadow registers, which are used for high priority interrupts and call fast are used by mplab icd 2. these are reserved resources for mplab icd 2 operation. a problem will be encountered if a breakpoint is set inside a call fast subroutine or inside the service routine for a high priority interrupt that uses the shadow registers with the return fast or retfie instruction. 8.2.20 q: when setting a breakpoint at the first location in my program, why does it stop at address 0001 rather than 0000? a: mplab icd 2 stops at the instruction after the breakpoint. this means that a breakpoint at address 0000 will be executed, then the program counter will be point ing at address 0001 when it gets a breakpoint. if a user needs to stop at the first instruction in their code, they must put a nop at address 0000. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 114 ? 2005 microchip technology mplab ? icd 2 user?s guide 8.2.21 q: why is my calibration memory displayed as the erase value? a: mplab ide is displaying the default memory value. a device read must be performed with mplab icd 2 to display the actual value on the device. 8.2.22 q: when single stepping through the code, my timer times out, but why does my timer interrupt routine not execute? a: when single stepping, the in-circuit debugger will not allow the picmicro mcu to respond to interrupts. if it did, and users had external interrupts, then single stepping would almost always end up in interrupt routines. to debug an interrupt, set a breakpoint inside the interrupt service routine and run to get a breakpoint after the interrupt. 8.2.23 q: how do i program a romless (pic18c601/ 801) device? a: for these devices, you must cr eate the routines that read/write memory. see section 4.5 ?romless device considerations? for details. 8.3 common communication problems the following are a list of common problems with mplab icd 2 communications, both usb and serial. 8.3.1 communications cannot be established with mplab icd 2 first, click debugger>connect . if you cannot establish communi- cations with mplab icd 2, follo w the steps below. if communica- tions still cannot be established, contact microchip engineering support. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
general troubleshooting ? 2005 microchip technology inc. DS51331B-page 115 8.3.1.1 in general 1. check that the rs-232 or usb cable is connected securely to the mplab icd 2 and the host computer. 2. check that the modular cable is connected securely to the demo board/target application and the mplab icd 2 module. 3. make sure there is power to the demo board/target application. check v dd source in the icd settings dialog, power tab. 4. check that the device is plugg ed into the demo board/target application correctly; e.g., all pins are plugged into the socket and the device is correctly oriented. 8.3.1.2 serial communications 1. make sure the power supply is connected and the power led on the mplab icd 2 module is on. 2. there may be a driver-hardware incompatibility; try changing flow control to hardware and/or turning off the fifo for the serial port. for specific instructions, see changing serial port settings. 3. check the settings on the icd setting dialog, communica- tion tab. make sure you selected the correct com port and baud rate for your application. 4. try connecting the mplab icd 2 module to a different port. when first connecting to the mplab icd 2, the default com port is com1. if you are usi ng the mplab icd 2 on another com port, select debugger>settings and then click the communications tab. set your com port and baud rate here. note: if you are having problems at a com port baud rate speed of 57600 , switch back to the initial speed of 19200 . www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 116 ? 2005 microchip technology mplab ? icd 2 user?s guide 5. make sure that a com port is properly set up exclusively for use by the debugger. check the resources to ensure they are operating properly and that there are no conflicts with other devices. this commonly happens when you have a modem or other serial device t hat is improperly configured. consult your windows manual or other reference literature. you can try removing, reconfi guring, or disabling the con- flicting device, but only do so if you are familiar with those procedures. 6. if you have a com port but mplab ide will not let you select it (the option is grayed out) you may be able to assign the port manually by editing the mplab.ini file. typically, this occurs if you have a gap in your com port list (i.e., you have a com1, com2, and a com4, but no com3). in this case you may be able to fix it by opening mplab.ini (use find to locate this file) and editing the section called [mplab icd 2] so that the setting commport=1 is set to the port you want selected. this is just a work-around to a deeper problem in which windows is incorrectly reporting port availability through the 16-bit driver. 8.3.1.3 usb communications 1. if mplab icd 2 is powering a target application, make sure a power supply is connected and the power led on the mplab icd 2 module is on. 2. make sure you have used the mplab ide supplied usb driver for mplab icd 2. caution if the windows os picked a usb driver, mplab icd 2 will not work. follow the instructions in driversnn\icd2_usb\ mpusbclean.htm (nn = windows os version) of the mplab ide installation directory to remove the windows drivers and replace them with the correct usb drivers. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
general troubleshooting ? 2005 microchip technology inc. DS51331B-page 117 8.3.2 connection failure occurs when using a com port 2, 3 or 4 when first connecting to the mplab icd 2, the default com port is com1. if you are using the mplab icd 2 on another com port, select debugger>settings and then click the communications tab. set your com port and baud rate here. 8.3.3 mplab icd 2 connects but target operations fail this can indicate that the v dd setting is incorrect. the mplab icd 2 can provide v dd to the target (5 volts only). this is set in the icd debugger settings dialog, power tab. if ?power target circuit from mplab icd 2? is selected, the mplab icd 2 will provide v dd to the target (the target does not need to be powered). however, if the target needs a voltage other than 5v or more than 200ma of current, then the target cannot be powered by mplab icd 2 and will require its own power source. when you click the reset button in debug mode to reset the program, it will go to zero and halt. the reset command will not rerun the program when the mplab icd 2 is in debug mode. 8.3.4 command to program/erase target memory failed make sure that you have selected the appropriate bus width and oscillator settings for the device you are programming. 8.3.5 programming error occurs when programming a range of memory on pic18c601/801 for the pic18c601/801, you need to align the end address + 1 so it can be divided by 8. for example, 0x7ff or 0x1fff7. if you receive a programming error due to an incorrect end address, you need to perform a reconnect, correc t the end address and select program again. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 118 ? 2005 microchip technology mplab ? icd 2 user?s guide changing serial port settings complete the following steps to change the flow control and fifo settings for a serial communicat ions port on a pc running the windows operating system. windows 98/me 1. on your pc, select start>settings>control panel . 2. in the control panel, double click the system icon. 3. in the systems properties dialog, click the device manager tab. 4. if necessary, expand the ports selection by clicking the ?+? sign next to it. 5. double click the i/o port to which the mplab icd 2 is connected. 6. in the flow control field, select hardware. 7. click the advanced button, deselect the ?use fifo? box, and click ok. 8. reboot the pc to implement the change. windows nt 1. on your pc, select start>settings>control panel . 2. in the control panel, double click the ports icon. 3. double click the i/o port to which the mplab icd 2 is connected. 4. select the port settings tab. 5. in the flow control field, select hardware. 6. click the advanced button, deselect the ?use fifo? box, and click ok. 7. reboot the pc to implement the change. note: you may need administrator privileges on your computer to change these settings. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
general troubleshooting ? 2005 microchip technology inc. DS51331B-page 119 windows 2000/xp 1. on your pc, select start>settings>control panel . 2. in the control panel, double click the system icon. 3. in the systems properties dialog, click the hardware tab and click the device manager button. 4. double click ?ports (com & lpt)? to expand the ports selection. 5. double click the i/o port to which the mplab icd 2 is connected. 6. select the port settings tab. 7. in the flow control field, select hardware. 8. click the advanced button, deselect the ?use fifo? box, and click ok. 9. reboot the pc to implement the change. 8.4 common problems the following are a list of common problems you may encounter. 8.4.1 debug mode not working 1. make sure you have selected all of the areas of the device that you want to program. select debugger>settings and click on the program tab. select memories as desired. 2. if you are using the start/end address fields in the memory addresses section of the icd settings dialog ( debugger> settings , program tab), ensure that the start address is set to the beginning of an 8-byte block and the end address is set to the end of an 8-byte block. for example, a start address of 0x10 and an end address of 0x1f. note: you may need administrator privileges on your computer to change these settings. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 120 ? 2005 microchip technology mplab ? icd 2 user?s guide 8.4.2 can't uncheck programming of configuration bits in debug mode for mplab icd 2 to function in debug mode, the icd must ensure that the background debug configuration bit is pro- grammed on the target. therefore, configuration memory is always programmed when in debug mode. 8.4.3 when single stepping, the program runs too slowly upload of data issue data is uploaded from the mplab icd 2 depending on the amount of data displayed in the ide, i.e., the size and amount of open debug windows. ? if your program is running slow, consider closing some windows or using watch windows to view specific registers. ? if not all register data is being updated, you probably do not have all the registers visible when you run/step. that is, if you step, then scroll to find a regi ster, it will not have the updated data from the step execution. 8.4.4 single stepping slow when programmer enabled if you have a programmer enabled when using mplab icd 2 to debug a part with eedata, your stepping through code will be very slow. disable the programmer to speed up stepping time. the slowdown occurs because the programmer must attach to the entire range of eedata so it can be programmed. the debugger, seeing that something is attached to the eedata (whether a programmer or eedata display) will read back the entire range after each step in case the data was modified while running. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
general troubleshooting ? 2005 microchip technology inc. DS51331B-page 121 8.4.5 when single stepping, the program runs too quickly or some registers are not updated this is an upload of data issue. see section 8.4.3 ?when single stepping, the program runs too slowly? . 8.4.6 when halting, single stepping, or stopping on a breakpoint, mplab ide seems to lock up your program may not have locked up, but may be running very slowly. this is an upload of data issue. see section 8.4.3 ?when single stepping, the program runs too slowly? . also, if you are using pic16f87x device, the first program memory location (address 0x0000) must be a nop instruction or you will not be able to single step past location zero. 8.4.7 the following i/o pins are not functioning correctly: rb6 or rb7 these pins are reserved for debugging. 8.4.8 one or more of my memory addresses (program or gpr) is not correct several gpr's and program memory locations are reserved for debugging. 8.4.9 eeprom window does not reflect changes in order to see the changes in the window, you must do a read of the memory. 8.4.10 stack window does not reflect changes/is blank this is a tool limitation. see chapter 11. ?limitations? . www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 122 ? 2005 microchip technology mplab ? icd 2 user?s guide 8.4.11 program keeps resetting see section 8.2.12 ?q: why does my program keep resetting?? . 8.4.12 execute reset or mclr command, program does not rerun when you select debugger>reset to reset the program, it will go to zero and halt. the reset command will not rerun the program when the mplab icd 2 is in debug mode. 8.4.13 file register window does not display top-of-stack registers the three top-of-stack registers (tosu, tosh and tosl) are not displayed in the file registers window when using the mplab icd 2. 8.4.14 power and busy led blink on and off see section 8.2.17 ?q: what would make the power and busy led blink on and off?? . 8.5 error and warning messages mplab icd 2 generates several error and warning messages. details on the meanings of most messages may be found in on-line help for mplab icd 2. warning messages may be selected to display or not display using the warnings tab of the settings dialog. all messages may be output to a file for debugging by selecting the ?output to debug file? checkbox on the status tab of the settings dialog. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
general troubleshooting ? 2005 microchip technology inc. DS51331B-page 123 8.6 limitations mplab icd 2 has limitations for both its debugger and programmer modes. these, and additional device-specific limitations, may be found in on-line help for mplab icd 2. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 124 ? 2005 microchip technology mplab ? icd 2 user?s guide notes: www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
? 2005 microchip technology inc. DS51331B-page 125 mplab ? icd 2 user?s guide chapter 9. hardware specifications 9.1 introduction hardware specifications for mplab icd 2 system components are listed here. in addition, please refer to the ?mplab icd 2 design advisory? (ds51566) for hardware configuration issues. topics covered in this chapter are: ? mplab icd 2 module ? modular cable and connector ? power supply 9.2 mplab icd 2 module the mplab icd 2 module contains all debugging, programming and control logic. it is connected to either a pc's serial port via a 9-pin serial cable or a usb po rt via a usb cable and to the picdem 2 plus demo board or target application using a 6-wire modular cable. the module contains the firmware to provide serial communica- tions to the pc, to drive the mplab icd 2 communications to the target application or demo board and to program a supported picmicro mcu device using icsp, all from the mplab ide. the module can provide power to the demo board/target application. v dd source is selected in the icd settings dialog, power tab. if the target application draws over 200 ma, an additional power adapter must be connected to the demo board or target applica- tion. the target application also provides power to the module only for the purpose of logic level conversion. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 126 ? 2005 microchip technology mplab ? icd 2 user?s guide the mplab icd 2 interface cable must be plugged into a modular connector on the application circuit with the appropriate connec- tions to the picmicro mcu device. the interface cable carries the signals necessary to allow in-circuit debugging of the target application. 9.3 modular cable and connector a modular cable connects the mplab icd 2 and the target application. the specifications for this cable and its connectors are listed below. 9.3.1 modular connector specification ? manufacturer, part number ? amp incorporated, 555165-1 ? distributor, part number ? digikey, a9031nd the following table shows how the modular connector pins on an application correspond to the microcontroller pins. this configuration provides the full mplab icd 2 functionality. www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
hardware specifications ? 2005 microchip technology inc. DS51331B-page 127 figure 9-1: modular connector pinout of designer's board www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 128 ? 2005 microchip technology mplab ? icd 2 user?s guide 9.3.2 modular plug specification ? manufacturer, part number ? amp incorporated, 5-554710-3 ? distributor, part number ? digikey, a9117nd 9.3.3 modular cable specification ? manufacturer, part number ? microchip technology, 07-00024 www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
hardware specifications ? 2005 microchip technology inc. DS51331B-page 129 9.4 power supply the mplab icd 2 module requires a 9.0 v, 750 ma power supply. the demo board or your target application may also require an additional power supply if it is drawing too much power from the mplab icd 2 module. the mplab icd 2 module can power a demo board/target application of up to 200 ma for 5 vdc. a power adapter is included in the following product kits: the power supply specifications for the mplab icd 2 module and the picdem 2 plus demo board are: ? dc power supply: 9 vdc @ 0.75a ? with barrel connector: id = 2.5 mm, od = 5.5 mm, barrel length = 10.0 mm, inside positive part number description includes these components dv164006 mplab icd 2 evaluation kit mplab icd 2 module, usb, mplab icd 2 interface and rs-232 cables, picdem 2 plus demo board, power adapter, mplab ide cd-rom dv164007 icd 2 module sw mplab icd 2 module, usb, icd 2 interface and rs-232 cables, power adapter, mplab ide cd-rom ac162048 rs-232 desk top kit power adapter and rs-232 cable www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 130 ? 2005 microchip technology mplab ? icd 2 user?s guide notes: www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
? 2005 microchip technology inc. DS51331B-page 131 mplab ? icd 2 user?s guide a abort ................................................................................... 75, 78 advanced ................................................................................. 67 advanced breakpoint dialog dspic devices ................................................................... 91 extended pic18f devices ................................................. 88 extended pic18f devices v2 ........................................... 89 pic18f devices ................................................................. 87 animate .................................................................................... 74 application code .................................................................... 100 av dd ................................................................................ 11, 100 av ss ................................................................................. 11, 100 b blank check ....................................................................... 41, 77 blinking led ........................................................................... 112 breakpoints ........................................................................ 37, 75 advanced ......................................................... 87, 88, 89, 91 setting ........................................................................ 56, 113 bsr register .......................................................................... 113 c calibration data .............................................................. 111, 114 call fast .................................................................... 101, 113 capacitors ................................................................................ 12 circuits that interfere with mplab icd 2 ................................. 12 code protect ............................................................ 14, 101, 110 communications ....................................................................... 29 configuration bits ......................................................... 14, 34, 52 index www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab ? icd 2 user?s guide DS51331B-page 132 ? 2005 microchip technology connecting ..................................................32, 33, 34, 45, 75, 78 connections ..............................................................................10 contact information ....................................................................5 creating a hex file ...................................................................51 customer notification service ....................................................4 d debug executive ............................................................17, 100, 109 registers ....................................................................18, 101 reserved resources ..........................................................18 resources ........................................................................101 debug mode requirements .....................................................................14 sequence of operations .....................................................15 debug tool ...............................................................................31 debugger menu ........................................................................55 debugging ..........................................................................36, 56 demo board ..............................................................................54 device selection .......................................................................31 download ............................................................................75, 78 drivers not found ...................................................................110 dspic silicon version information ............................................34 e eedata ...................................................................................111 eeprom ..................................................................................38 eeprom data memory, start of .............................................69 environment setup ...................................................................34 erase ..................................................................................41, 77 erase all before pr ogramming .........................................53, 111 external memory, romless devices ........................................71 www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
? 2005 microchip technology inc. DS51331B-page 133 index f fast call ........................................................................... 101, 113 interrupts .......................................................................... 101 return .............................................................................. 113 firmware .................................................................................. 97 firmware upgrades .................................................................. 67 frequently .............................................................................. 107 g getting started ......................................................................... 27 gp0, gp1 ................................................................................. 19 gp1/ra1 ................................................................................ 112 gpio ...................................................................................... 112 green light ......................................................................... 31, 45 h halt ........................................................................................... 74 header board ........................................................................... 18 hex file ........................................................................ 38, 51, 68 hold in reset ............................................................................ 77 how mplab icd 2 works .......................................................... 8 i icd ........................................................................................... 97 cable ................................................................................. 10 header adapters .............................................................. 108 -icd devices ............................................................................ 72 ice vs icd .................................................................................. 8 icsp ....................................................................... 14, 18, 20, 22 installation ................................................................................ 29 interconnections ....................................................................... 10 internal buffer circuits .............................................................. 98 internet address, microchip ........................................................ 3 interrupts ................................................................................ 112 fast .................................................................................. 101 high priority ..................................................................... 113 www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab ? icd 2 user?s guide DS51331B-page 134 ? 2005 microchip technology l linker script file .......................................................................69 loading program and debug code ..........................................54 low voltage ............................................................................109 lvp .........................................................................................110 m mclr ................................................................19, 20, 22, 26, 77 modular interface cable ...............................................10, 14, 28 mpasm assembler ...................................................................47 mplab ........................................................................................7 mplab.exe .................................................................................30 o operating system u pgrades ....................................................67 oscillator, target ......................................................................99 p pgc, pgd ........................................... .......................11, 26, 107 pic18f452 ................................................................................43 picdem 18r ............................................................................70 picdem 2 plus demo board .....................................................43 port b ......................................................................................112 power ......................................................................................108 sequence ...........................................................................32 target .................................................................................98 program ..............................................................................75, 77 device for debug ................................................................36 mode ..................................................................................18 tab, settings dialog ...........................................................53 programmer ..............................................................................39 programming ............................................................................61 programming options ...............................................................52 project .......................................................................................35 project wizard ..........................................................................47 pull-ups .....................................................................................12 www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
? 2005 microchip technology inc. DS51331B-page 135 index r rb6, rb7 ........................................................................... 20, 22 read ................................................................................... 75, 77 read a device .......................................................................... 40 real-time execution ................................................................ 37 red light .................................................................................. 31 release from reset .................................................................. 77 reserved resources ................................................................ 18 reset hold in ................................................................................ 77 processor ........................................................................... 75 release from ..................................................................... 77 resistors .................................................................................. 12 retfie .................................................................................. 113 return fast ........................................................................ 113 romless devices ..................................................................... 70 rs-232 ..................................................................................... 28 run ........................................................................................... 74 s selecting device and development mode ............................... 45 self test ................................................................................. 113 set breakpoint .......................................................................... 56 setting program and debug options ....................................... 51 setting up hardware and software .......................................... 44 settings dialog ......................................................................... 35 setup wizard ...................................................................... 45, 84 shadow stack ........................................................................ 101 single stepping ...................................................................... 114 stack ............................................................................ 19, 20, 22 status register ....................................................................... 113 step .......................................................................................... 74 step-mode execution ............................................................... 38 support ....................................................................................... 1 system components ................................................................ 28 www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
mplab ? icd 2 user?s guide DS51331B-page 136 ? 2005 microchip technology t table read protect ...........................................................14, 101 target device ................................................................................97 oscillator .... ........................................................................99 power .................................................................................98 timers .............................................................................112, 114 toolbar buttons ........................................................................55 tos ..........................................................................................22 troubleshooting ........................................................................95 tut452.asm ................................................................................55 source code ......................................................................62 tutorial ......................................................................................43 u updating firmware ...................................................................46 usb ..........................................................................................28 drivers ........................................................................96, 108 hub ...................................................................................108 v v dd ...........................................................................................11 verify ...................................................................................40, 77 w w register ..............................................................................113 watch window ..........................................................................58 watchdog timer .......................................................................14 web site, microchip ....................................................................3 windows device manager ......................................................108 y yellow light ..............................................................................31 www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
? 2005 microchip technology inc. DS51331B-page 137 index notes: www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com
DS51331B-page 138 ? 2005 microchip technology inc. americas corporate office tel: 480-792-7200 fax: 480-792-7277 technical supp ort: 480-792-7627 web address: http:// www.microchip.com atlanta tel: 770-640-0034 fax: 770-640-0307 boston tel: 978-692-3848 fax: 978-692-3821 chicago tel: 630-285-0071 fax: 630-285-0075 dallas tel: 972-818-7423 fax: 972-818-2924 detroit tel: 248-538-2250 fax: 248-538-2260 kokomo tel: 765-864-8360 fax: 765-864-8387 los angeles tel: 949-263-1888 fax: 949-263-1338 san jose tel: 650-215-1444 fax: 650-961-0286 toronto tel: 905-673-0699 fax: 905-673-6509 asia/pacific australia - sydney tel: 61-2-9868-6733 fax: 61-2-9868-6755 china - beijing tel: 86-10-85282100 fax: 86-10-85282104 china - chengdu tel: 86-28-86766200 fax: 86-28-86766599 china - fuzhou tel: 86-591-7503506 fax: 86-591-7503521 china - hong kong sar tel: 852-2401-1200 fax: 852-2401-3431 china - shanghai tel: 86-21-6275-5700 fax: 86-21-6275-5060 china - shenyang tel: 86-24-2334-2829 fax: 86-24-2334-2393 china - shenzhen tel: 86-755-82901380 fax: 86-755-8295-1393 china - shunde tel: 86-757-28395507 fax: 86-757-28395571 china - qingdao tel: 86-532-5027355 fax: 86-532-5027205 china - xian tel: 86-29-8833-7250 fax: 86-29-8833-7256 china - wuhan tel: 86-27-5980-5300 fax: 86-27-5980-5118 india - bangalore tel: 91-80-2229-0061 fax: 91-80-2229-0062 india - new delhi tel: 91-11-5160-8631 fax: 91-11-5160-8632 india - pune tel: 91-20-2566-1512 fax: 91-20-2566-1513 japan - yokohama tel: 81-45-471- 6166 fax: 81-45-471-6122 korea - seoul tel: 82-2-554-7200 fax: 82-2-558-5932 or 82-2-558-5934 malaysia - penang tel: 604-646-8870 fax: 604-646-5086 philippines - manila tel: 011-632-634-9065 fax: 011-632-634-9069 singapore tel: 65-6334-8870 fax: 65-6334-8850 taiwan - kaohsiung tel: 886-7-536-4818 fax: 886-7-536-4803 taiwan - taipei tel: 886-2-2717-7175 fax: 886-2-2545-0139 taiwan - hsinchu tel: 886-3-572-9526 fax: 886-3-572-6459 thailand - bangkok tel: 66-2-694-1351 fax: 66-2-694-1350 europe austria - weis tel: 43-7242-2244-399 fax: 43-7242-2244-393 denmark - ballerup tel: 45-4450-2828 fax: 45-4485-2829 france - massy tel: 33-1-69-53-63-20 fax: 33-1-69-30-90-79 germany - ismaning tel: 49-89-627-144-0 fax: 49-89-627-144-44 italy - milan tel: 39-0331-742611 fax: 39-0331-466781 netherlands - drunen tel: 31-416-690399 fax: 31-416-690340 england - berkshire tel: 44-118-921-5869 fax: 44-118-921-5820 06/29/05 worldwide sales and service www.datasheet www.datasheet www.datasheet www.datasheet 4u 4u4u 4u .com .com .com .com


▲Up To Search▲   

 
Price & Availability of DS51331B

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X